简体   繁体   English

矩阵的二维二维曲面图细节不够

[英]rgl 2D surface plot of matrix not enough detail

I am trying to use rgl to surface plot this matrix "r": 我正在尝试使用rgl表面绘制此矩阵“ r”:

library(rgl)             

          Banana      Apple   BlueBerry Kiwi      Raisin      Strawberry
Chicago   1.0000000 0.9972928 0.9947779 1.0623767 0.9976347   0.9993892
Wilmette  1.0016507 1.0000000 0.9976524 0.9863927 0.9985248   1.0016828
Winnetka  1.0040722 1.0025362 1.0000000 0.9886008 1.0016501   0.9955785
Glenview  0.9961316 1.0105463 1.0167024 1.0000000 1.0129399   1.0123440
Deerfield 1.0023308 1.0026052 0.9979093 0.9870921 1.0000000   1.0025606
Wheeling  1.0073697 0.9985745 1.0045129 0.9870925 1.0008054   1.0000000


rgl.surface(1:6 , 1:6 , r, color="red", back="lines")

Since the z-values are so close together in magnitude, the surface plot looks almost flat, even though there are subtle bumps in the data. 由于z值在幅度上非常接近,因此即使数据中存在细微的凹凸,表面图看起来也几乎是平坦的。

1) How do I make it so that I have a zoomed in version where I can see as much detail as possible? 1)我该如何做才能拥有放大的版本,以便可以看到尽可能多的细节?

2) Is there a way to show in different colors the data (faces) that have the biggest "slope", and so that the labels of the columns and rows of the matrix are preserved on the 3D surface (maybe just using the first three letters of the labels)? 2)是否有办法以不同的颜色显示出来从而使列矩阵的行的标签的3D表面上保存的数据具有最大的“斜率”(面)(也许只用前三标签的字母)? In other words, so I can see that the Kiwi in Chicago and the Kiwi in Wilmette causes the greatest min/max variation? 换句话说,所以我可以看到芝加哥的奇异果和威尔米特的奇异果引起最大/最小变化?

Something like this? 像这样吗

library(rgl)
library(colorRamps)         # for matlab.like(...)
palette <- matlab.like(10)  # palette of 10 colors
rlim    <- range(r[!is.na(r)])
colors  <- palette[9*(r-rlim[1])/diff(rlim) + 1] 

open3d(scale=c(1/6,1/6,1/diff(range(r))))
surface3d(1:6 , 1:6 , r, color=colors, back="lines")

Part of your problem is that you were using rgl.surface(...) incorrectly. 问题的部分原因是您错误地使用了rgl.surface(...) The second argument is the matrix of z-values. 第二个参数是z值的矩阵。 With surface3d(...) the arguments are x, y ,z in that order. 使用surface3d(...) ,参数surface3d(...)为x,y,z。

EDIT : Response to OP's comment. 编辑 :对OP的评论的回应。

Using your ex post facto dataset... 使用事后数据集...

open3d(scale=c(1/6,1/6,1/diff(range(r))))
bbox3d(color="white")
surface3d(1:6 , 1:6 , r, color=colors, back="lines")
axis3d('x--',labels=rownames(r),tick=TRUE)
axis3d('y-+',labels=colnames(r),tick=TRUE)
axis3d('z--',tick=TRUE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM