问题
I build a vector d
of POSIXlt dates. I make a plot(d, x)
using this vector as axis x. but on the plot dates are printed using my computer's locale. I need them to use different locale. how can i choose the format/locale to be used on plots?
回答1:
You should be able to use on Unix based system:
Sys.setlocale("LC_TIME", "en_US");
This works for me:
Sys.setlocale("LC_TIME","ru_RU")
df = data.frame(date=c("2012-02-01", "2012-02-01", "2012-02-02"))
df$day <- weekdays(as.Date(df$date))
df$value <- c(1,10,5)
plot(df$value, xaxt="n")
axis(side=1, labels=df$day, at=c(1,2,3))
Sys.setlocale("LC_TIME","en_US")
df = data.frame(date=c("2012-02-01", "2012-02-01", "2012-02-02"))
df$day <- weekdays(as.Date(df$date))
df$value <- c(1,10,5)
plot(df$value, xaxt="n")
axis(side=1, labels=df$day, at=c(1,2,3))
来源:https://stackoverflow.com/questions/32553466/r-plot-dates-in-specific-locale