i'm trying to plot a geom_ribbon with y = consumption and x = date with a format %m-%d.
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()
But when I run the code, I get the below error :
Error: Invalid input: date_trans works with objects of class Date only
Thank you for your help!