简体   繁体   中英

Plotting 3D Surface Chart

I'm new to R and am trying to plot a 3D surface. I thought it would be a pretty simple process as I have all my data in a nice table but can't figure out where I'm going wrong.

my_data2 (read in from Excel):

               X1      X1.1     X1.21     X1.33     X1.46     X1.61     X1.77     X1.98     X2.14     X2.35
 4e+05   291208737 291296846 291744988 292676157 304539662 347763047 346637087 352381080 361467196 334153676
 5e+05   301234194 301322304 342042259 344633543 346394275 347763047 392216772 376048898 361467196 334153676

The first column is my row headers.

I've tried a few different R packages but am obviously missing something.

I thought it would be as simple as:

> r <- 1:nrow(my_data2)
> c <- 1:ncol(my_data2)
> z <- c(my_data2)
> contour3D(x=r, y=c, z=z, colvar=Volcano)

Error message displayed: "exactly one of the values 'x' 'y', or 'z' should be a matrix or one value"

I thought my z variable was a matrix!

Can anyone please help? Tks

from the help page: "contour3D adds a contour in a 3-D plot." So I think you actually want something else. Maybe something like this:

library(plot3D)
z <- as.matrix(my_data2)
hist3D(z=z)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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