1

I'm using the code below for the daily weather:

library(ggplot2)
options(repr.plot.width=16, repr.plot.height=9)

ggplot(df,aes(x = Date, y = MADRID)) +
  geom_line(group = 1, color='lightblue')+
  scale_y_continuous(limits = c(5,30), breaks = seq(5,30,5)) +
  ggtitle ("Daily average temperature - MADRID") +
  xlab("Date") +  ylab ("Average Temperature ( ºC )")

And getting such a graph:

enter image description here

My question, how to get labels with years having daily data on the x axis?

Adolf Miszka
  • 208
  • 1
  • 9
  • 1
    You already have the dates there (there are so many that they overprint and give you the black lines). Take a look at (say) https://stackoverflow.com/a/30020683 to see how to alter the breaks – Hobo May 23 '21 at 23:12

1 Answers1

2

Add something like:

plot + scale_x_date(labels = date_format("%d/%m/%Y"), breaks = date_breaks("1 year"))
mlcyo
  • 544
  • 1
  • 3
  • 11