手动定义线框的颜色 [英] Manually defining the colours of a wireframe

查看:89
本文介绍了手动定义线框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用晶格封装在R中绘制一些曲面.我找不到选择表面颜色的方法.这是一个示例:

I am plotting some surfaces in R using the lattice package. I can't find a way to choose the colours of the surface. Here is an example:

这是我如何绘制每个图的示例:

Here is an example of how i plot each:

theseCol=heat.colors(150)
mm=paste("WB numbers where present\n(",nstoch," sims)",sep="")
WBnumbers=wbPrev_series
rownames(WBnumbers)=KList
colnames(WBnumbers)=iMwbList
wireframe(WBnumbers, zlim=c(0,max(wbPrev_series,na.rm=TRUE)), colorkey=FALSE, 
                    col.regions=theseCol, scales = list(arrows = FALSE), drape = TRUE, 
                    main=mm,  zlab="", xlab="K", ylab="iMwb")

我希望第一表面保持原样,但其他表面不按其z级别着色,而是按第一个表面的z级别着色.我尝试了多种方法,但线框始终接受我给出的颜色作为当前变量的可能范围.

I would like for the first surface to be as it is, but for the others to be coloured not by their z levels but by the 1st surface's z levels. I tried multiple things but wireframe always accepts the colours i give as the possible ranges for the current variable.

无论如何可以做到这一点? 谢谢

Anyway this could be done? Thanks

推荐答案

以下是Dave W.几年前在R-help邮件列表中发布的答案.您可能可以用谷歌搜索整个线程.

Here is the answer Dave W. posted some years back on the R-help mailing list. You probably can google up the entire thread.

来自:David Winsemius 按照help(wirefrane)中的建议,您需要查看
有关建议的levelplot部分:对colorkey的正确规范
并点击帮助页面中的相应链接.是否为您的数据
无法从包含的附件​​中确定线框的正确输入
信息,尽管我认为您报告的成功表明确实如此.

From: David Winsemius Following the advice in help(wirefrane) you need to look at the
levelplot section for advice re: a proper specification to colorkey
and follow the appropriate links in the help pages. Whether your data
is a proper input to wireframe cannot be determined from the included
information, although I suppose your reported success suggests it is.

这是未经测试的(因为没有要测试的内容)狂妄猜测
看完材料后,我指出:

This is an untested (since there was nothing to test) wild-assed guess
after reading the material I pointed to:

wireframe(data.m,aspect = c(0.3), shade=TRUE, screen = list(z = 0, x =  
-45),
    light.source = c(0,0,10), distance =  
0.2,zlab="Freq",xlab="base",ylab="Fragment",
    col=level.colors(x, at = do.breaks(range(data.m), 30),
                     col.regions = colorRampPalette(c("red", "white",  
"blue")(30))
       )

根据Josh的要求,我玩了一些.以下将应用阴影(悬垂):

Per Josh's request, I played around a bit. The following will apply color shading (drape):

wireframe(dmat,drape=TRUE,col='black',col.regions = colorRampPalette(c("red", "white",  "blue"))(30) )

哪个设置悬垂"颜色,但不设置网格线本身. wireframe不尊重par(new=TRUE)真是可惜,因为如果这样做,我们可以将数据矩阵切成z范围并一次绘制一种颜色.

Which sets the "drape" colors but not the gridlines themselves. It's a darn shame that wireframe doesn't respect par(new=TRUE), because if it did we could slice the data matrix into z-ranges and overplot one color at a time.

回到家时,我将不得不检查带有R图形的旧实验的存档",但我认为我最终还是使用了scatterplot3d包来获取与数据相关的网格颜色.

I will have to check my "archive" of old experiments w/ R graphics when I get home, but I think I ended up using the scatterplot3d package to get data-dependent grid colors.

这篇关于手动定义线框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆