Aliases: axis
Keywords: aplot
### ** Examples require(stats) # for rnorm plot(1:4, rnorm(4), axes = FALSE) axis(1, 1:4, LETTERS[1:4]) axis(2) box() #- to make it look "as usual"
plot(1:7, rnorm(7), main = "axis() examples", type = "s", xaxt = "n", frame.plot = FALSE, col = "red") axis(1, 1:7, LETTERS[1:7], col.axis = "blue") # unusual options: axis(4, col = "violet", col.axis = "dark violet", lwd = 2) axis(3, col = "gold", lty = 2, lwd = 0.5)
# one way to have a custom x axis plot(1:10, xaxt = "n") axis(1, xaxp = c(2, 9, 7))
## Changing default gap between labels: plot(0:100, type="n", axes=FALSE, ann=FALSE) title(quote("axis(1, .., gap.axis = f)," ~~ f >= 0)) axis(2, at = 5*(0:20), las = 1, gap.axis = 1/4) gaps <- c(4, 2, 1, 1/2, 1/4, 0.1, 0) chG <- paste0(ifelse(gaps == 1, "default: ", ""), "gap.axis=", formatC(gaps)) jj <- seq_along(gaps) linG <- -2.5*(jj-1) for(j in jj) { isD <- gaps[j] == 1 # is default axis (1, at=5*(0:20), gap.axis = gaps[j], padj=-1, line = linG[j], col.axis = if(isD) "forest green" else 1, font.axis= 1+isD) } mtext(chG, side=1, padj=-1, line = linG -1/2, cex=3/4, col = ifelse(gaps == 1, "forest green", "blue3"))
## now shrink the window (in x- and y-direction) and observe the axis labels drawn