4

I want to use a color scale that seems somewhat common (look here and here), but I couldn't find it anywhere. It's not rainbow() or heat.colors() or any other here; and http://colorbrewer2.org/ also don't display it (or at least I couldn't find it). Any help, please? If it's in the basic packages, yet better!

Community
  • 1
  • 1
Rodrigo
  • 4,706
  • 6
  • 51
  • 94

2 Answers2

5

Using rich.colors from gplots for the first link, and contrary to your post, RColorBrewer "spectral" palette for the second link, or even the palette that is designed to ape the default matlab colour palette, which is blue2green2red from colorRamps?

require( gplots )
barplot( rep(1,100), width = rep(2,100) , col=rich.colors(100), space = 0 , border=0, axes=FALSE)

require( RColorBrewer )
display.brewer.pal(11 , "Spectral" )

require( colorRamps )
image(matrix(1:400, 20), col = blue2green2red(400) , axes = FALSE)

enter image description here

Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
  • Thanks for the answer, Simon! I'll keep with the other since it doesn't need an external library, though. – Rodrigo Aug 21 '13 at 16:02
5

That looks like Matlab's Jet colours, they are replicated in ?colorRampPalette:

## 'jet.colors' is "as in Matlab"
## (and hurting the eyes by over-saturation)
jet.colors <-
  colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
                     "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))

And an example:

filled.contour(volcano, color = jet.colors, asp = 1, nlevels=100)
James
  • 65,548
  • 14
  • 155
  • 193