7

I have the following plot:

enter image description here

and I want to change the x-axis label so that I either have "May" instead of "Mai" (preferred) or if that fails something like "14-05-21 18:00" in which the full date and the hour are given.

The code I use for the plot is:

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 the x-axis has the class

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

with the format

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

Any ideas?

Anne
  • 377
  • 2
  • 4
  • 16
  • 3
    You probably just need to change your locale. See `help("Sys.setlocale")`. – Roland Oct 13 '14 at 17:38
  • I tried that before and made a silly mistake, thinking it doesn't work.. It does now, thanks for making me retry! – Anne Oct 13 '14 at 18:50
  • Does this answer your question? [axis labels are not plotted in English](https://stackoverflow.com/questions/15438429/axis-labels-are-not-plotted-in-english) – David Richfield Apr 04 '20 at 18:23

1 Answers1

1
Sys.setlocale("LC_ALL", "English")
Julien
  • 1,613
  • 1
  • 10
  • 26