2017-08-01 70 views
1

我想展开一个定性调色板的颜色以获得更多信息的栅格图。展开栅格图的定性调色板R

我一直在使用rasterVis包和特别情节我需要比Paired调色板更多的颜色。

levelplot(..., 
     par.settings = rasterTheme(region = brewer.pal(10,'Paired')), 
     at=seq(0,5000,500), 
     ...) 

通过这个配置,我得到一个光栅从0到5000增加200个单位。 rasterTheme函数让我根据Paired调色板使用10个不连续的颜色作为绘图。

Paired调色板只有12种颜色,如果我想要25种颜色(光栅从0到5000增加200个单位),我必须使用预定义的调色板,这意味着使用顺序调色板。

levelplot(..., 
     par.settings = YlOrRdTheme, 
     at=seq(0,5000,200), 
     ...) 

我怎么能使用25种不同颜色的非连续调色板?我应该手动创建一个调色板还是有一个函数来创建随机调色板?

谢谢!

回答

0

randomcoloR有两个函数用于创建具有自变量的随机颜色,用于选择所需颜色的数量。使用distinctColorPalette功能的示例:

# load the library 
library(randomcoloR) 

# define the number of colors 
k <- 25 

# generate the colors 
colors <- distinctColorPalette(k = k) 

# proof - plot the colors 
xleft <- seq(1,k,1) 
xright <- xleft+1 
ybottom <- rep(0,k) 
ytop <- ybottom+1 
plot(1, 1, xlim = c(0, k), type = "n", axes = FALSE, bty = "n", xlab = "", 
    ylab = "") 
rect(xleft = xleft, ybottom = ybottom, xright = xright, ytop = ytop, col = 
    colors, border = "white")