11.28 Colour Ranges

20200608

Automatic colour ranges are supported using grDevices::palette(), as the default palette. A contiguous colour palette is available as grDevices::cm.colors(), with a rainbow available as grDevices::rainbow(). Others palletes includegrDevices::gray(), which provides a gray scale, colorRamps::blue2green2red(), and RColorBrewer::brewer.pal().

blue2green2red(15)
##  [1] "#0000CC" "#0000FF" "#0055FF" "#00AAFF" "#00FFFF" "#2BFFD5" "#55FFAA"
##  [8] "#80FF80" "#AAFF55" "#D4FF2B" "#FFFF00" "#FFAA00" "#FF5500" "#FF0000"
## [15] "#CC0000"

Use graphics::image() to display the colour plots as above.

image(matrix(1:80,  10), col=palette())
image(matrix(1:100, 10), col=cm.colors(10))
image(matrix(1:100, 10), col=rainbow(10))
image(matrix(1:60,  10), col=gray(seq(0.1, 0.9, len=6)))
image(matrix(1:150, 10), col=blue2green2red(15))
image(matrix(1:110, 10), col=brewer.pal(11, "PRGn"))
image(matrix(1:110, 10), col=brewer.pal(11, "RdBu"))
image(matrix(1:80,  10), col=brewer.pal(8,  "Accent"))
image(matrix(1:80,  10), col=brewer.pal(8,  "Dark2"))
image(matrix(1:90,  10), col=brewer.pal(9,  "Pastel1"))
image(matrix(1:120, 10), col=brewer.pal(12, "Paired"))
image(matrix(1:120, 10), col=brewer.pal(12, "Set3"))


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0