线框表面图上非高度变量的颜色

时间:2019-10-01 19:00:37

标签: r lattice wireframe

我有兴趣将我的数据显示为一堆棋盘,并且正方形上的颜色编码反映了感兴趣的变量。使用groups软件包中wireframe命令中的lattice参数,我能够生成一个堆叠的棋盘格框架。

gridlocs <- expand.grid(xval=1:4,
                        yval=1:4,
                        zval=1:3)
gridlocs$height <- c(rep(0,16), rep(50,16), rep(100,16))
gridlocs$colors <- rnorm(48, 7, 2)

testcols <- level.colors(gridlocs$colors, 
                          at= do.breaks(range(gridlocs$colors), 12), 
                          col.regions = heat.colors)

wireframe(height ~ xval + yval, groups=zval, data=gridlocs, 
          aspect=c(1,2), drape=FALSE,
          col=testcols)

但是,由于wireframe的默认着色方案是按z变量着色,所以我无法弄清楚如何独立于棋盘格的高度对正方形的背景着色。

下图是在图形软件中编辑的,反映了我可能希望该图看起来如何。棋盘的位置很好,我想知道如何根据数据框中的另一个变量({{1}以外)来填充正方形。

我也很高兴接受height以外的软件包中的答案。

enter image description here

0 个答案:

没有答案