0

I have some data:

> head(dat)
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14
1:  2  2  3  2  4  1  1  0  0   0   2   2   0   0
2:  0  0  0  0  0  0  0  0  0   0   0   0   0   0
3:  0  0  0  0  0  0  0  0  0   0   0   0   0   0
4:  0  0  0  0  0  1  0  0  0   0   0   0   0   0
5:  0  0  0  0  0  0  0  0  0   0   1   1   0   0
6:  0  0  0  0  0  0  0  0  0   0   0   0   0   0

How can I create a 3D plot of this data, so X axis would be V1:V14, Y axis would be 1:6(Index) and Z axis would be the value of V1[1]?

When I try to plot I get:

> scatter3D(dat)
Error in range(y, na.rm = TRUE) : 'y' is missing

What should I parse as Y and Z?

4d4c
  • 8,049
  • 4
  • 24
  • 29
  • which library is `scatter3d` from? – CHP Mar 14 '14 at 01:56
  • [scatter3d](http://cran.r-project.org/web/packages/scatterplot3d/index.html), I don't mind using any other library – 4d4c Mar 14 '14 at 02:00
  • Can you provide additional explanation of what you're trying to do? For a 3D scatterplot, wouldn't you plot 3 variables (columns) at a time (e.g., V1, V2, and V3). These would be the x, y, and z values. – eipi10 Mar 14 '14 at 04:02
  • `scatter3d` is in the `car` package. You could also try the `rgl` package and use the `plot3d` function to produce an animated plot that you can rotate. For a static plot, you could try the `scatterplot3d` package. – eipi10 Mar 14 '14 at 04:08

1 Answers1

1

You'll want to play around with the arguments, but wireframe is nice.

library(lattice)
d <- as.matrix(dat)
wireframe(d, scales = list(arrows = FALSE),
          drape = TRUE, colorkey = TRUE,
          screen = list(z = 30, x = -60))

enter image description here

Rich Scriven
  • 97,041
  • 11
  • 181
  • 245