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')

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", font.lab=2, xaxs='i', yaxs='i', xlim=c(0, 20), ylim=c(0,25), panel.first = grid(nx=NA, ny=NULL, lty=1, col="gray"), xlab="X", ylab="f(X)") abline(a=0, b=0, lwd=3)

- col = "navy" makes the line color navy blue. Web RGB hex strings can also be used (ex. "#000080" for navy)
- lwd = 3 makes the line width 3 pixels. Actual unit is device specific
- las = 1 makes all axis labels horizontal
- fg = "white" changes the foreground color to white so no border or axis lines are visible
- font.lab = 2 makes the axis labels bold
- xaxs = "i" and yaxs = "i" makes the X- and Y-axis extend the full height of the chart rather than being padded
- xlim and ylim set the ranges for the X and Y axes, respectively, so the automatic ranges don't give odd intervals
- panel.first defines a function run after the plot is set up but before the points are drawn. This is used so grid lines are behind the points
- xlab and ylab set the X and Y axis labels, respectively
- abline() draws the dark black line on the X-axis