开发者

3D visualization using R

开发者 https://www.devze.com 2023-03-26 06:05 出处:网络
I have a set of values, w, for each (x,y,z). I want to visualize this 4D data as an interactive 3D image plot.

I have a set of values, w, for each (x,y,z). I want to visualize this 4D data as an interactive 3D image plot.

That is, each 3D pixel x,y,z should get some color based on w.

PS: w ranges from 0-7, and the rest of the (x,yz) are jus开发者_运维技巧t transparent.


Here is an example. Note that your z data needs to be a matrix with x rows and y columns.

library(rgl)
set.seed(1)
x <- seq(1,10)
y <- seq(1,10)
w <- runif(100)
z <- runif(100)

wcolors <- rainbow(length(w))[rank(w)]
zmat <- matrix(z, length(x),length(y))

persp3d(x=x, y=y, z=zmat, col = wcolors)
0

精彩评论

暂无评论...
验证码 换一张
取 消