[R] adding infrequent date labels to x-axis
hrishimittal at gmail.com
Mon Feb 22 19:36:18 CET 2010
You are right. I tried the command only with one year's data, in which case
it plots month names as labels. But for multiple years, the labels become
years. I found this old post useful -
Picking the code from the comment by Gavin Simson, I think this should work:
ticks.at <- seq(min(x), max(x), by = "months")
## format the labels as abbreviated month names
ticks.lab <- format(ticks.at, format = "%b")
## indicator variable; is month January?
m1 <- ticks.lab == "Jan"
## plot small ticks and labels for months not Jan
Axis(x, at = ticks.at[!m1], side = 1,
labels = ticks.lab[!m1], las = 2, cex.axis = 0.7)
## plot the default tick locations for years
Axis(x, side = 1, las = 2)
## add the box
Try http://prettygraph.com Pretty Graph , the easiest way to make R-powered
graphs on the web.
View this message in context: http://n4.nabble.com/adding-infrequent-date-labels-to-x-axis-tp1564804p1564924.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help