[英]Plot 3d with y as point, x and z as vectors in R?
I want to plot 3D figure in R where I have y has fixed point and x and z are vectors. 我想在R中绘制3D图,其中我有y有固定点,而x和z是向量。 For example:
例如:
x=[1,2,4,8,16,32,64]
y=0
z=[100,200,300,400,500,600,700]
x=[1,2,4,8,16,32,64]
y=1
z=[...] // 7 points
and so on till y = 10 依此类推,直到y = 10
I tried to use wireframe
where y = 1, and I always have error like that: 我尝试使用其中y = 1的
wireframe
,并且总是出现如下错误:
Error in eval(substitute(groups), data, environment(formula)) :
numeric 'envir' arg not of length one
Can anyone helps me to get that data plotted? 谁能帮我绘制这些数据?
y
must equal 1 for all values of x
and z
to plot in 3D. y
必须等于1,才能在3D模式下绘制x
和z
所有值。 And it must be in matrix
form. 并且必须为
matrix
形式。
> x <- c(1,2,4,8,16,32,64)
> y <- rep(1, 7)
> z <- c(100,200,300,400,500,600,700)
> d <- matrix(c(x, y, z), 7, 3)
> d
## [,1] [,2] [,3]
## [1,] 1 1 100
## [2,] 2 1 200
## [3,] 4 1 300
## [4,] 8 1 400
## [5,] 16 1 500
## [6,] 32 1 600
## [7,] 64 1 700
> library(lattice)
> wireframe(d, scales = list(arrows = FALSE),
drape = TRUE, colorkey = TRUE,
screen = list(z = 30, x = -60))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.