Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating 3D plots in R with arbitrary data points and viewpoints

Tags:

plot

r

I want an R function that will let me do the following two things simultaneously:

  1. Plot arbitrary piecewise functions like scatterplot3d. That is, it should let me specify a arbitrary set of 3d coordinates at which points will be plotted.
  2. Let me set the viewpoint of the graph to arbitrary angles along both axises, like persp.

plot3d is not acceptable as it only allows manual adjustment of the plots once they are generated. I want to be able to script this.

like image 832
John Doucette Avatar asked Oct 12 '11 00:10

John Doucette


1 Answers

In a pckage I'm currently developing, addendum, there is a function plot4d that gives a neat example if how to do that with rgl. You don't have to use the package for it: just rip the source of the function.

(note: you may get 2 warnings when loading the package - this is because of a minor glitch in the otherwise beautiful glmnet package, and doesn't break anything.)

like image 133
Nick Sabbe Avatar answered Oct 10 '22 04:10

Nick Sabbe