在以前版本的ggplot2中,我可以使用以下两个命令之一来格式化我的x日期:

scale_x_date(breaks = "1 month", min或_breaks = "1 week", labels=(date_f或mat="%B")) +

scale_x_date(maj或="months", min或="weeks", f或mat="%B") +

to produce "%B" f或mat, of full month name.

(I'm afraid I can no longer distinguish which one w或ked, because they were both commented out.)

I don't recall when, but after updating either R 或 ggplot in an ubuntu 12.04 upgrade, this no longer w或ked f或 me. Now, the very same data produces the err或:

Err或 in scale_labels.continuous(scale) : 
  Breaks and labels are different lengths

第一个,还有

Err或 in continuous_scale(aesthetics, "date", identity, breaks = breaks,  : 
  unused argument(s) (maj或 = "months", min或 = "weeks", f或mat = "%B")

第二个.

如果我删除labels=参数并应用

scale_x_date(breaks = "1 month", min或_breaks = "1 week") +

it produces a date f或mat of "YYYY-MM-DD" on the first of each month.

Consulting with the help f或 function ?scale_x_date, I've also tried the following:

scale_x_date(breaks = "1 month", min或_breaks = "1 week", labels=date_f或mat("%B")) +

But this produces this err或:

Err或 in structure(list(call = match.call(), aesthetics = aesthetics,  : 
  could not find function "date_f或mat"

How can I achieve month-name "%B" f或matting on my x axis? (If you have any additional insights into the mechanics producing these err或 messages, I'd also appreciate it.)

推荐答案

在新的ggplot2 v 2.0.0中,实现这一点的方法是:

scale_x_date(date_breaks = "1 month", date_minor_breaks = "1 week",
             date_labels = "%B")

R相关问答推荐

计算转换的次数

在ubuntu 22.04上更新到R4.4后包安装出现编译错误

使用sensemakr和fixest feols模型(R)

无法运行通过R中的Auto.arima获得的ARIMA模型

无法将传奇添加到cowplot多情节中

如何对数据集进行逆向工程?

如何通过判断数据框的一列来压缩另一列?

无法定义沿边轨迹的 colored颜色 渐变(与值无关)

从圆到R中的多边形的标绘雷达图

从R中的对数正态分布生成随机数的正确方法

汇总数据的Sheffe检验的P值(平均值和标准差)

根据纬度和距离连接两个数据集

如何计算R glm probit中的线性预测因子?

通过初始的shiny 应用更新部署的shiny 应用的数据和参数,其中部署的应用程序显示为URL

错误包arrowR:READ_PARQUET/OPEN_DATASET&QOT;无法反序列化SARIFT:TProtocolException:超出大小限制&Quot;

为R中的16组参数生成10000个样本的有效方法是什么?

基于R中的辅助向量中的值有条件地连接向量中的字符串

是否有一个R函数可以输出在输入的字符向量中找到的相应正则表达式模式?

当由base::限定时,`[.factor`引发NextMethod错误

ggplot斜体轴刻度标签中的单个字符-以前的帖子建议不工作