[R] Plotting an ellipse in 3D

Duncan Murdoch murdoch at stats.uwo.ca
Fri Sep 9 15:02:58 CEST 2005


Mike White wrote:
> I have been using the ellipse function from the car package and the
> covariance matrix to draw an ellipse around a group of points to show the
> confidence limits.  However, the points are actually represented by 3
> variables so rather than plot each pairwise combination of variables in 2D I
> would like to plot the 'ellipse' in 3D using the djmrgl package.  Can anyone
> offer advice on how I can plot the surface of  a 3D 'ellipse' using the
> covariance matrix to define the shape, so that the points inside can also be
> seen.

You should use rgl, rather than djmrgl.  It now has most of the same 
functions plus a lot more.

Then you can plot the ellipse as a wireframe or transparent object.  See 
the demo(regression) example for that kind of drawing; demo(shapes3d) 
for ellipses.  (The demo names are from memory, I don't have access to 
it right now.)

Duncan Murdoch




More information about the R-help mailing list