R: ggplot2 change time axis language

I have the following graph:

enter image description here

and I want to change the x-axis label to either "May" instead of "May" (preferred) or something like "14-05-21 18:00" which gives the full date and the hour.

The code I'm using for the graph:

library(ggplot2)
library(grid)
ggplot(day5, aes(datetime)) + 
  geom_line(aes(y = ET.Lys, colour = "ET.Lys")) + 
  geom_line(aes(y = ET.PM, colour = "ET.PM"))+
  scale_y_continuous(breaks=c(0,0.2, 0.4, 0.6, 0.8, 1, 1.2), limits=c(0,1.2)) +
  xlab("\n date and time") +
  ylab("ET [mm/h]\n") +
  theme_bw(25)+
  theme(legend.title=element_blank(),
        legend.justification = c(1, 1), legend.position = c(1,1), 
        legend.background=element_rect(color = "grey",fill = "white", size = 0.1, linetype = "solid"),
        legend.key = element_blank(),
        legend.text=element_text(size=20))+
  geom_line(aes(y = ET.Lys, colour = "ET.Lys"),  size=1)+
  geom_line(aes(y = ET.PM, colour = "ET.PM"),  size=1)+
  theme(plot.margin=unit(c(0.5,2,0.5,0.5), "cm"))

      

and the datetime variable on x axis has class

> class(day5$datetime)
[1] "POSIXct" "POSIXt" 

      

with format

format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT+0"

      

Any ideas?

+3


source to share





All Articles