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.
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:
References
Harrower, Mark, and Cynthia A. Brewer. 2003. “ColorBrewer.org: An Online Tool for Selecting Colour Schemes for Maps.” The Cartographic Journal 40 (1): 27–37. https://doi.org/10.1179/000870403235002042.