Customize plot axes

No votes yet

If you're not happy with what R puts on the axes of your plot (tickmarks, labels etc), plot with "axes=F", then add custom axes with the "axis()" function.

Example:

budget <- 360
plotmax <- budget+30
w1 <- 134
w2 <- 70
w3 <- 70
w4 <- 60
weeks <- matrix(c(w1,w2,w3,w4))
par(las=1) # we want all labels to be horizontal
# draw the plot without axes:
barplot(weeks, beside=F, ylim=c(0,plotmax),xlim=c(0,2),axes=F)
# draw one custom axis, in grey, that sets tickmarks at 10,20,30 etc
axis(2,at=seq(0,plotmax,by=10),col="grey",labels=F)
# draw another axis on top of it that draws black tickmarks at 50,100 etc
# and that labels these numbers
axis(2,at=seq(0,plotmax,by=50),col="black")