5.3 Colours

5.3.1 Using the Brewer palettes:

The easiest way to change the colour palette of your ggplot() is to specify a Brewer palette (Harrower and Brewer (2003)):

Note that http://colorbrewer2.org/ also has options for Colourblind safe and Print friendly.

5.3.2 Legend title

scale_colour_brewer() is also a convenient place to change the legend title (Figure 5.5):

Note the \n inside the new legend title - new line.

p9: choosing a Brewer palette for your colours. p10: changing the legend title.

FIGURE 5.5: p9: choosing a Brewer palette for your colours. p10: changing the legend title.

5.3.3 Choosing colours manually

R also knows the names of many colours, so we can use words to specify colours:

The same function can also be used to use HEX codes for specifying colours:

Colours can also be specified using words (`"red"`, `"green"`, etc.), or HEX codes (`"#8dd3c7"`, `"#ffffb3"`, etc.).

FIGURE 5.6: Colours can also be specified using words ("red", "green", etc.), or HEX codes ("#8dd3c7", "#ffffb3", etc.).

References

Harrower, Mark, and Cynthia A. Brewer. 2003. “ColorBrewer.org: An Online Tool for Selecting Colour Schemes for Maps.” The Cartographic Journal 40 (1). Taylor & Francis: 27–37. https://doi.org/10.1179/000870403235002042.