0

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!

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
  • 1
    Please add a small example of your dataset. See [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for some ideas on how to do this. – aosmith Aug 23 '17 at 16:04
  • 1
    I suggest to edit your post and add the output of `dput(df)`. It would be easier for the SO community to help you. – Marco Sandri Aug 23 '17 at 21:36

0 Answers0