2

我想用网格包绘制色阶。像 heat.plot (10) 这样的东西。

在此处输入图像描述

我正在尝试这样的事情:

require(grid)
legendViewport <- viewport(height=0.3, width=0.8)
pushViewport(legendViewport)
grid.rect(gp = gpar(col = "gray90"))

假设我想将 0 划分为 1,分成 10 并填充 heat.colors (10)。有没有简单的方法来做到这一点。

4

1 回答 1

2

如果你只想要颜色,

grid.raster(t(heat.colors (10)), 
   width=unit(1,"npc"),
   height=unit(1,"npc"), int=FALSE)
于 2012-07-29T23:56:37.427 回答