Formatting Charts in R

The default plot() layout is functional, but of dubious aesthetic value. While the ggplot2 does somewhat better, it is possible to configure the native plot() command with a few extra parameters.

This is an example of a default plot:

x = 0:20
y = x + runif(length(x))

plot(x, y, type='l')
plot() with default parameters

This particular layout is clean and minimalist:

x = 0:20
y = x + runif(length(x))

plot(x, y, type='l', 
	col="navy", lwd=3,
	las=1, fg="white",
	xaxs='i', yaxs='i',
	xlim=c(0, 20), ylim=c(0,25),
	xlab="X", ylab="f(X)")

grid(nx=NA, ny=NULL, lty=1, col="#00000040")

abline(a=0, b=0, lwd=3)
Improved plot() layout