我试图用y =消费绘制geom_ribbon,用格式%m-%d绘制x = date。
df$date <- as.Date((paste(df$annee, df$mois, df$jour, sep='-')), "%Y-%m-%d")
df$monthday <- as.Date(df$monthday, format = "%m-%d")
g1 <- ggplot(df) +
geom_ribbon(aes(ymin=min, ymax=max, x = monthday), data=df, group = 1) +
geom_line(aes(y=mean, x=monthday), group = 1) +
scale_x_date(date_labels = "%m-%d", date_breaks = "1 month")
library(gridExtra)
pdf("plot.pdf")
grid.arrange(g1, ncol=1)
dev.off()
但是当我运行代码时,我得到以下错误:
错误:输入无效:date_trans仅适用于类Date的对象
感谢您的帮助!