How do I generate a mapping from numbers to colors in R?

后端 未结 4 666
刺人心
刺人心 2021-02-15 13:45

In R, I can easily generate a color ramp, for example colorRampPalette. The following produces a sequence of five colors, from blue to red:

> mypal <- colo         


        
4条回答
  •  [愿得一人]
    2021-02-15 14:31

    You can try

    > colorRampPalette(c('blue', 'red'))(length(x))[rank(x)]
    [1] "#0000FF" "#FF0000" "#CC0032" "#3300CC" "#660099" "#990065"
    

提交回复
热议问题