Skip to content

Instantly share code, notes, and snippets.

@domwom
Created August 25, 2009 22:06
Show Gist options
  • Select an option

  • Save domwom/175071 to your computer and use it in GitHub Desktop.

Select an option

Save domwom/175071 to your computer and use it in GitHub Desktop.
R
## some dummy data
x <- seq(as.Date("2008-01-01"), as.Date("2009-10-31"), by = "day")
set.seed(1234)
y <- cumsum(rnorm(length(x)))
## plot, but suppress axes
plot(y ~ x, type = "l", axes = FALSE)
## add in axis on side 2
axis(2)
## compute where we want the ticks for the months
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
box()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment