0

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!

Zuriel
  • 1

1 Answers1

0

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.

Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
  • Hi! Thank you for your reply. Somehow this is the error message I'm getting: Error: unexpected symbol in: "zindex <- unlist(sapply(1:nrow(data.set), function(j) which(zu==data.set[j,3])) scatterplot3d" My data set is actually 70000+ data points, with 43 unique z-values but I thought I'd simplify my question. Haha. Thanks! – Zuriel Jul 15 '14 at 14:15
  • You don't want "scatterplot3d" in that line of code. – Carl Witthoft Jul 15 '14 at 15:42
  • It was actually the parentheses that I didn't realize was missing. But thank you for your help! – Zuriel Jul 15 '14 at 23:31