I have (x,y) data where x = months(Jan 2020-March 2021) and y = values,
I am plotting all of these on the same graph, just by there months, I would like to distingush between the years by changing the color of the x label months (jan 2020- dec 2020) to be the color blue and the data labeled Jan 2021 - March 2021 to be labeled green.
I would also like to have a legend that shows the year 2020 is blue on the x axis and 2021 is green.
example of data would be :
data:
dates = seq.Date(from =as.Date("01/01/2020", "%d/%m/%Y"),
to=as.Date("01/03/2021", "%d/%m/%Y"), by="month")
y = c(1:1:15)
df = data.frame(dates,y)
when plotting, would like x axis label df$dates[1:12]
to be the color blue and df$dates[13:15]
to be color green