Search code examples
rcolorscolor-palette

Wide Range of the same Color in R


Is it possible to create great number of different kinds of "red" color. For better understanding I am expecting following, but instead of grey I desire to have "red" or "red-black".

mypalette <- rev(grey.colors(10000, start = 0.1, end = 0.5, gamma = 4))
plot(1:length(mypalette),1:length(mypalette), col=mypalette, pch=16)

The color packages I know have limited range of colors. Any idea will be appreciated.


Solution

  • If I understand what you want, try colorRampPalette. It returns a function that outputs the requested number of colours between the two you specified.

    reds <- colorRampPalette(c("black","red"))
    reds(5)
    [1] "#000000" "#3F0000" "#7F0000" "#BF0000" "#FF0000"