Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
自定义R中image.plot的颜色范围_R_Plot_Colors - Fatal编程技术网

自定义R中image.plot的颜色范围

自定义R中image.plot的颜色范围,r,plot,colors,R,Plot,Colors,在image.plot()函数中,是否有方法绘制zlim截止点以上的值?下面是一个例子: library('gplots') library('fields') library('RColorBrewer') rf <- colorRampPalette(rev(brewer.pal(11,'Spectral'))) # make colors r <- rf(64) z <- matrix(data = 0, nrow = 3, ncol = 3) z[1,1] &l

在image.plot()函数中,是否有方法绘制zlim截止点以上的值?下面是一个例子:

library('gplots')
library('fields')
library('RColorBrewer')

rf <- colorRampPalette(rev(brewer.pal(11,'Spectral')))   # make colors
r <- rf(64)

z <- matrix(data = 0, nrow = 3, ncol = 3)
z[1,1] <- .15
z[2, ] <- .10
z[3, ] <- .05

image.plot(z,
           col = r,
           zlim = c(0, .10))
library('gplots')
库('字段')
库('RColorBrewer')

rf作为一种快速技巧,只需在颜色渐变中多重复几次最终颜色,使该区域的颜色渐变“平坦”。因此,最高的
z
值都将具有相同的颜色:

library('gplots')
library('fields')
library('RColorBrewer')

# Original 11 colors
cols = rev(brewer.pal(11,'Spectral'))

# Repeat the 11th color an extra 5 times
cols = c(cols,rep(cols[11],5))

rf <- colorRampPalette(cols)   # make colors
r <- rf(64)

z <- matrix(data = 0, nrow = 3, ncol = 3)
z[1,1] <- .15
z[2, ] <- .10
z[3, ] <- .05

image.plot(z, col = r, zlim = c(0, .15))

是的,但这也颠覆了传说。如果您可以找到一种方法来缩小图例,使其仅显示值0-.10,那么您就有了一个可行的解决方案。
# Cover legend
rect(1.3,-1,1.6,2, col="white", border="white", xpd=TRUE)

# Go back to original 11 colors for color ramp
cols = rev(brewer.pal(11,'Spectral'))
rf <- colorRampPalette(cols)   # make colors
r <- rf(64)

# Plot only the legend with z cutoff at 0.10
image.plot(z, col = r, zlim = c(0, .10), legend.only=TRUE)