5Graphics

Producing high‐quality graphics is one of images's strong points as it offers almost complete control over the look of plots. The particular plot function needed will depend on the number and type of variables you want to plot.

In this introductory chapter on creating graphics, we'll first look at the basics of plotting in images. Various plotting functions are then dealt with under four headings:

  • plots for single variables;
  • plots for two variables;
  • plots for three or more variables;
  • plotting functions.

5.1 Plotting principles

A plot should be clear, readable, and serve a purpose. It shouldn't be so busy or cluttered that the main message is obscured, nor should its interpretation (or the reason for its inclusion in a report, say) be left to the audience to guess. This depends, at least in part, on having:

  • appropriate graphic type;
  • appropriate graphic size;
  • descriptive title(s) or caption(s);
  • informative labels on axes;
  • appropriate number of ‘tick marks’ on axes;
  • suitable font and font size for labels and titles;
  • strategic use of colour;
  • clear legends where necessary.

There are many more aspects we could list here, but this is a good start.

This section is intended to give an overview of the most basic features of plotting – axes, titles, and colour – for which we'll use

Get The R Book, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.