Colour

We have been adding colour to our plots by colouring the points by their Species. In this lesson we will learn more ways to add colour to our plots and learn some about the colouring system.

Solid Colours

In the next code editor we will colour the points in the plot all one solid colour, rather than varying them. We can do this by adding the argument color to the relplot function.

In this code editor we colour the points purple by setting the argument value equal to the string purple. There are plenty of other colours available such as: green, pink, red, brown, blue, etc. Go ahead and change the colour in this code editor to see the colour changes!

R interactive coding assignment

Hexadecimal for Colours

While there is a fixed set of colours that we can use as in the above list. We can dramatically expand our colour palette by learning the hexadecimal colour code system.

The hexadecimal colour code system is a 6-symbol code made up of 3 pairs of 2-symbol codes, representing the intensity of red, green, and blue (RGB) in the colour, respectively. Hexadecimal refers to the base-16 number system, which uses sixteen distinct symbols. The symbols include 0-9 and the letters A-F, where the letters represent the values eleven to sixteen as single characters.

In the context of color codes, these hexadecimal values can range from 00 to FF, allowing for 256 different levels of intensity for each of the red, green, and blue components, resulting in over 16.7 million possible colors (256 x 256 x 256).

Let's consider a shade of purple, which is often a mixture of high intensity of red and blue with a lower intensity of green. A common purple shade could have a hexadecimal code of #800080. Breaking this code down:

  • 80: Represents a moderate level of red.
  • 00: Represents no green.
  • 80: Represents a moderate level of blue.

With this knowledge, we can go to a website such as colorhexa.com and explore colours to find the hexadecimal representation. In the next example we demonstrate how we expand our colour pallete by showing a shade of light purple in hexadecimal form: #EEDBFE (this is our brand colour!). Since this shade is not a standard colour, we can only paint with it by its hexadecimal form.

R interactive coding assignment

Being able to express the data in simple to understand graphics can sometimes go a lot farther in explaining the data more than any amount of tables, summaries or equations. And further finding the perfect colour palette for the presentation of the graphic, such as combining the colours of your school or company, can make the graphic stand out and be more memorable.