Axes

The axes of a graph often need some attention. Again, here are only some very first thoughts.

Range of axes

The range of the axes is determined automatically. If you want a different range, use xlim=c(#lower,#upper) and/or ylim=c(#lower,#upper), where "#lower" and "#upper" are to be replaced by the respective values.

Tick marks and their labels

Most graphs will have tick marks with labels that indicate the value on the x and y axis.

Upright labels on the y axis

By default, the labels on the y axis are rotated by 90 degrees anti-clockwise. However, when the numbers displayed are small, why not present them upright? This can be easily accomplished by adding las=1 (with the number 1, not the lower-case letter l).

Suppressing an axis

For some reason or other, you may wish to suppress one or more axes on a graph. This can be accomplished with xaxt="n" and/or yaxt="n, respectively.

Note that this need not imply that the space where the axis (or axes) used to be will be white. As plots are often surrounded by boxes, there may remain a line; removing the axis here means only to remove the tick marks and their labels. If you wish to remove the box (or parts of it), use the bty parameter as explained here.

© W. Ludwig-Mayerhofer, R Guide | Last update: 03 Apr 2017