在r中的网格图中绘制颜色比例

时间:2012-07-29 21:41:32

标签: r colors fill r-grid

我想用网格包绘制色标。像heat.plot(10)之类的东西。

enter image description here

我正在尝试这样的事情:

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

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

1 个答案:

答案 0 :(得分:2)

如果你只想要颜色,

grid.raster(t(heat.colors (10)), 
   width=unit(1,"npc"),
   height=unit(1,"npc"), int=FALSE)