从X,Y,Z data.frame制作线框阴谋 [英] Making a wireframe plot from an x,y,z data.frame
问题描述
我有X / Y / Z点data.frame。我知道如何使用 RGL
包制作3D散点图,但我想每个点连接在散点图制作线框或曲面图。
I have a data.frame of x/y/z points. I know how to make a 3d scatterplot using the rgl
package but I would like to connect each point in the scatterplot to make a wireframe or surface plot.
这code返回散点图
library(rgl)
Data <- expand.grid(x=seq(0,10),y=seq(0,10))
Data$z <- Data$x^2+Data$y^2
plot3d(Data)
虽然这code返回空白图:
While this code returns a blank graph:
plot3d(Data,type='wire')
我可以做的情节,我想与格:
I can make the plot I want with lattice:
library(lattice)
wireframe(z~x+y,Data)
我甚至可以让它旋转:
I can even make it rotate:
library(TeachingDemos)
rotate.wireframe(z~x+y,Data)
但我preFER RGL
在格
,因为它渲染更快,可以旋转的情节鼠标。
But I prefer rgl
over lattice
because it renders much quicker and lets you rotate the plot with the mouse.
请告诉我正确的方式,使在 RGL
?
Whats the proper way to make a wireframe plot in rgl
?
推荐答案
在表面拉丝绘图功能在RGL的persp3d而像基地:: persp,它需要一个矩阵的输入与z参数
The surface drawing plot function in rgl is persp3d and like base::persp, it needs a matrix as input to the z argument
zmat <- matrix(Data$z, 11,11)
persp3d(x=seq(0,10), y=seq(0,10), z=zmat)
我做一个屏幕抓取程序我用它拍摄前旋转这个图形了一下:
I did spin this graphic a bit before capturing it with a screen grabbing program I use:
这篇关于从X,Y,Z data.frame制作线框阴谋的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!