I am writing a proposal and need a 3D plot something like this:
but preferably more attractive. I need the size of each point to reflect the abundance of the species and an outline of the volume created by connecting the points.
Sample data:
input<-data.frame(
label=c("sp1","sp2","sp3","sp4"),
trait_x=c(6,6,6,1),
trait_y=c(7,7,7,1),
trait_z=c(8,8,8,1),
point_size=c(6,7,8,1)
)
input
label trait_x trait_y trait_z point_size
1 sp1 6 7 8 6
2 sp2 6 7 8 7
3 sp3 6 7 8 8
4 sp4 1 1 1 1
Any suggestion on how to make such a graph more attractive (perhaps including gridlines? I do not want any numbers on the axes however)
I have played around with scatterplot3d
, but it doesn't plot all my points and I personally find that the cube has a strange look to it... like it is not quite accurate...
library(scatterplot3d)
x<-input$trait_x
y<-input$trait_y
z<-input$trait_z
scatterplot3d(x,y,z,xlim=c(0,10),ylim=c(0,10),zlim=c(0,10))
This should get you started using package
rgl
. Note: On re-read I see I am using your xyz coords a little different than you did, but the concept is the same.Now you can rotate your diagram interactively and then use
rgl.snapshot
to get a hardcopy (using antialias arguments in spheres3d will improve the diagram).