Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Map the continuous variable to size or colour. In the heightweight data set, there are many columns,
but we’ll only use four of them in this example:
library(gcookbook)# For the data set# List the four columns we'll useheightweight[,c("sex","ageYear","heightIn","weightLb")]sex ageYear heightIn weightLb f11.9256.385.0f12.9262.3105.0f12.7563.3108.0...m13.9262.0107.5m12.5859.387.0
The basic scatter plot in Making a Basic Scatter Plot shows the relationship between
the continuous variables ageYear and
heightIn. To represent a third
continuous variable, weightLb, we
must map it to another aesthetic property. We can map it to colour or size, as shown in Figure 5-9: