简体   繁体   中英

R Scatterplot3d

I have two questions.

  1. My data set consists of four columns of data - x, y, z, function, let's say lambda. I'm trying to plot the density of the data for each unique value of z. For instance I have 1000 data points, out of which there are 10 unique z's. This means I would have a cube with a spectrum of 10 colors. How should I do this?

So far I have:

colorSet <- tim.colors(10)
z <- unique(data.set[,3])
something <- ??? Not sure if something should be done about this
scatterplot3d(data.set[,1], data.set[,2], data.set[,3], color=colorSet[something], pch=19)
  1. If I wish to add a third plane to a scatterplot, how can this be done?

So far (in pseudo-code) I have:

p1 <- scatterplot3d(etc)
col2 <- color for p2
p2$points3d(etc)

I'm not exactly sure how to go about with xyz.convert and plane3d because what I've read/searched up online don't seem to be working for me. :(

Hope someone can help! Thank you!

Since data.set[,3] has only 10 unique values, I believe you can simply set up a "lookup table" for the z values.

zu<-unique(data.set[,3])
zindex <- unlist(sapply(1:nrow(data.set), function(j) which(zu==data.set[j,3]))
scattterplot3D(data.set[,1],data.set[,2],data.set[,3],color=colorSet[zindex])

I haven't tested that so I may have fouled some index up.

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