Section 13 Base Graphics

  • The original R graphics package is referred to as base graphics.

  • Successive functions to add graphics and build plots up.

  • Function: high-level \(\large \longrightarrow\) Create new graphs

  • Function: low-level \(\large \longrightarrow\) Annotate plots

  • Default graphics parameters can be altered to customise the plot

13.1 High Level Graphics

Function Explanation
plot Scatterplot
pairs Scatterplot matrix
coplot Conditioning plot
hist Histogram
stem Stem-and-leaf plot
boxplot Box-and-whisker plot
qqnorm Quantile-quantile plot
barplot Bar plot
dotchart Dot plot
interaction.plot Profile plot of group means

13.2 Low Level Graphics

Function Explanation
points Plot points at given coordinates
lines Draw lines between given coordinates
text Draw text at given coordinates
mtext Draw text in the margins of a plot
abline Draw a line of given intercept and slope, or a horizontal and/or vertical line
axis Add an axis
arrows Draw arrows
segments Draw line segments
rect Draw rectangles
polygon Draw polygons
box Draw a box around the plot
grid Add a rectangular grid
legend Add a legend (a key)
title Add labels

13.3 Graphics Parameters

  • For detailed helps on graphics parameters: ?par
Function Explanation
main Title of the plot
ylab, xlab Labels for the y-axis and x-axis
ylim, xlim Limits for the y-axis and x-axis
type Plot type (points, lines, both, …),
pch Plot character (circles, dots, triangles, symbols, …)
cex Character expansion (size of plot characters)
lty Line type (solid, dots, dashes, …)
lwd Line width
col Colour of plot characters
las Orientation of the text on the tick marks