Ggplot2 ignores LC_TIME locale category?

I want to build a time series with ggplot() , a timeline created using strptime() .

So far, good: I get German abbreviations for months on the time axis, my language is set to Sys.setlocale("LC_TIME"="de_DE.UTF-8") . When I do months() with my data, they also appear in German.

Strange: when I set my locale to Sys.setlocale("LC_TIME"="en_GB.UTF-8") , months() will give me the English months, BUT ggplot() will continue to have GERMAN abbreviations for several months on the time axis .

I tried the other Sys.setlocale() categories, but to no avail.

Where can ggplot() get information about which language to choose?

+6
source share
4 answers

I understand how late I am with this answer, but I have the same problem and came across your thread looking for a solution.

For me

 Sys.setenv(LANGUAGE="en") Sys.setlocale("LC_TIME", "English") 

I decided.

+3
source

Have a look? Constants, and then change the value of month.abb to what you want. Maybe:

  month.abb <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") 
0
source

OK, this is a little strange.

with a fresh workspace (for example, after starting R) ggplot () can be affected by Sys.setlocale (). After the first drawing has been executed with one data parameter, other locales will be ignored for this data frame.

0
source

The easiest way to make it work:

 Sys.setlocale("LC_ALL", "en_US.UTF-8") 

After that, all ggplots have corresponding date stamps.

If you need to change only the time format, this should be enough:

 Sys.setlocale("LC_TIME", "en_US.UTF-8") 
0
source

Source: https://habr.com/ru/post/917884/


All Articles