Section 20 R Colours: col

20.1 Graphics Parameters

  • For detailed helps on graphics parameters: ?par

  • R Colour is defined by the attribute colour or col

  • R Colour can be defined by:
    • by colour number: 1 to 7; colour 8 is light grey
    • by colour name: e.g. ‘red’ as an element of colours()
    • by a hexadecimal string of the form #RRGGBB
    • by an integer subscript i on the current palette()[i]
    • by package RColorBrewer
  • To see all 657 colors defined by R, type colours()

20.2 Colour by Number

20.3 Colour by Name

Source: http://bxhorn.com/r-color-tables/

20.4 Colour by Hexadecimal String

Source: http://www.visibone.com

20.5 Colour by Palette

  • Create a vector of n contiguous colors using the following functions:
    • rainbow(n)
    • heat.colors(n)
    • terrain.colors(n)
    • topo.colors(n)
    • cm.colors(n)

20.6 Package RColorBrewer

  • The package RColorBrewer provides a combination of selected colours together into a set of palettes.