2012-07-29 90 views
2

我想用網格包繪製色彩座標。像heat.plot(10)。在網格圖中繪製色彩座標r

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)。有沒有簡單的方法來做到這一點。

+0

'grid.raster(heat.colors(10))' – baptiste 2012-07-29 22:12:38

+0

嘗試[這一個](https://gist.github.com/3202137)也許,或瀏覽lattice或ggplot2的源代碼 – baptiste 2012-07-29 22:17:22

回答

2

如果你只是想顏色,

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