Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot2 ignoring locale category LC_TIME?

Tags:

r

ggplot2

locale

I want to plot a time series with ggplot(), time line created with strptime().

So far ok: I am getting German abbreviations for the months on the time axis, my locale is set to Sys.setlocale("LC_TIME"="de_DE.UTF-8"). When I do months() with my data, they show up in German, too.

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

I've tried some other categories of Sys.setlocale() but to no avail.

Where does ggplot() take the information about which language to choose?

like image 750
lambu0815 Avatar asked Jun 12 '12 12:06

lambu0815


2 Answers

I realize how late I am with this response, but I got the same problem and stumbled on your thread while looking for solution.

For me

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

solved it.

like image 182
Nikolay Nenov Avatar answered Sep 28 '22 12:09

Nikolay Nenov


The easiest way to make it work is:

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

After that all ggplots have a proper date labels.

If you need to change only the time format this should suffice:

Sys.setlocale("LC_TIME", "en_US.UTF-8")
like image 36
haddr Avatar answered Sep 28 '22 13:09

haddr