[R] rgl: plot3d and ellipse3d

Yihui Xie xieyihui at gmail.com
Wed Sep 17 14:56:26 CEST 2008


Hi Michael,

You need to specify both 'box' and 'axes' to FALSE to avoid the box
lines (if you don't specify the latter one, there will still be axes
lines).

Best,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Wed, Sep 17, 2008 at 8:34 PM, Michael Friendly <friendly at yorku.ca> wrote:
> Hi
> I'm trying to make a 3d plot showing a point cloud, the corresponding data
> ellipse
> and the principal axes of the ellipse as vectors.
>
> library(rgl)
> data(trees)
> cov <- cov(trees)
> mu <- mean(trees)
>
> plot3d(trees, type="s", size=0.5, col="blue", cex=2)
>
> In this step, an extra box is added.  I've tried using box=FALSE, but it has
> no effect.
> # how to avoid the extra box?
> plot3d( ellipse3d(cov, centre=mu, level=0.68), col="pink", alpha=0.2,  add =
> TRUE)
>
> Here's what I've tried to plot the principal axes in variable space, using
> the result of prcomp().
> But I've got something wrong, because, although they are at right angles,
> they don't
> align with the ellipse.
>
> PC <- princomp(trees)
> sdev <- PC$sdev         # component standard deviations
> sd <- sqrt(diag(cov))   # variable standard deviations
>
> # vectors in variable space of principal components
> vec <- matrix(mu,3,3, byrow=TRUE) + diag(sd) %*% PC$loadings
>
> for (j in 1:3) {
>  mat <- rbind(mu, vec[j,])
>  segments3d(mat, col="red")
> }
>
> Can someone help?
>
> thanks,
> -Michael
>
>
> --
> Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology
> Dept.
> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT  M3J 1P3 CANADA
>



More information about the R-help mailing list