Producing high-quality graphics is one of the main reasons for doing statistical computing. The particular plot function you need will depend on the number of variables you want to plot and the pattern you wish to highlight. The plotting functions in this chapter are dealt with under four headings:
Changes to the detailed look of the graphs are dealt with in Chapter 29.
5.1 Plots with two variables
With two variables (typically the response variable on the y axis and the explanatory variable on the x axis), the kind of plot you should produce depends upon the nature of your explanatory variable. When the explanatory variable is a continuous variable, such as length or weight or altitude, then the appropriate plot is a scatterplot. In cases where the explanatory variable is categorical, such as genotype or colour or gender, then the appropriate plot is either a box-and-whisker plot (when you want to show the scatter in the raw data) or a barplot (when you want to emphasize the effect sizes).
The most frequently used plotting functions for two variables in R are the following:
5.2 Plotting with two continuous explanatory variables: Scatterplots
The plot function draws axes and adds ...