The colours of the Rainbow

There are several ways to specify colours in R.

plot(1:10, col="red") # red - obviously
plot(1:10, col=2)     # red - 2nd colour of the default palette
plot(1:10, col="#ff0000") # red - hexadecimal

The list of the 657 colours that R knows by name can be found with the the function colour( ) or color( ), and begins

[1] “white” “aliceblue” “antiquewhite” “antiquewhite1” “antiquewhite2” “antiquewhite3” “antiquewhite4” “aquamarine” “aquamarine1” “aquamarine2” “aquamarine3” “aquamarine4” “azure” “azure1” “azure2” “azure3” “azure4” “beige” “bisque” “bisque1” “bisque2” “bisque3” “bisque4” “black” “blanchedalmond” “blue” “blue1” ….

But what sort of colour is bisque, and how does antiquewhite differ from beige?

Here is code for a colour chart that can you help pick the colour you want

x11();par(mar=rep(0,4))#no margins
plot(grd, col=cols, pch=16, axes=FALSE, cex=2)
cols[identify(grd, labels=cols, cex=.7)]

Click on a colour you like, and its name will appear on the plot. When you have enough colours, click stop, and R will give you the names you clicked on.

If you want a sequence of colours, rather than just a single colour, there are the built-in colour sequences like rainbow( ) and heat.colours( ), or you can make your own colour sequences with colorRampPalette( ).

# ten colours from part of a rainbow
plot(1:10, col=rainbow(n=10, start=0, end=4/6), pch=16)

#thirty colours from a sequences from red to blue via white

About richard telford

Ecologist with interests in quantitative methods and palaeoenvironments
This entry was posted in R and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s