0

I have 3 data ranges using to plot in R:

x <- c(1,2,3,4,5)
y <- c(2,4,6,8,10)
z <- c(100,240,480,580,880)

How to plot a 3D graphic with those data in R (a 3d scatterplot) ?

roberutsu
  • 353
  • 2
  • 5
  • 15
  • 1
    does [**this post**](http://stackoverflow.com/questions/6720526/plotting-3d-data-in-r) help? – Arun Feb 08 '13 at 18:02
  • Ok, corrected. Sorry for the simplicity of this post, maybe I'd like to put the question and answer in the stackoverflow forum (I really used instead google). But I added the 3d scatterplot there. Thank you Guys. – roberutsu May 09 '13 at 00:33

2 Answers2

5

There are many examples of this available with a bit of searching.

Some ideas:

install.packages("scatterplot3d")
library(scatterplot3d) 


s3d <-scatterplot3d(x,y,z, pch=16, highlight.3d=TRUE,
  type="h", main="3D Scatterplot")

enter image description here

Sometimes it is nice if you can rotate it:

install.packages("rgl")
library(rgl)

plot3d(x, y, z, col="red", size=3)
Seth
  • 4,745
  • 23
  • 27
0

If you're looking for another option, you could use the plotly package for R.

library(plotly)

x <- c(1,2,3,4,5)
y <- c(2,4,6,8,10)
z <- c(100,240,480,580,880)

plot_ly(x = x, y = y, z = z, type="scatter3d", mode="markers")
d-roy
  • 759
  • 2
  • 8
  • 10