[R] drawing a specific "plane" with scatterplot3d

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jul 31 21:14:11 CEST 2012


On 12-07-31 2:54 PM, Andras Farkas wrote:
> Dear All,
>
> using the example from the package scatterplot3d I created a 3d plot as follows:
>
> x <-rnorm(500,50,2)
> y <-rnorm(500,5,1)
> z <-rnorm(500,6,1)
> scatterplot3d(x, y, z, highlight.3d=TRUE, col.axis="blue",col.grid="lightblue", main="scatterplot3d - 1", pch=20)
>
> I would like to ask if anyone could help me with the following:
>
> 1. I would like to draw  a plane across the plot that is paralell to the bottom of the plot and is in the heights of the value 6 on the axis "z", and goes across the plot

This is hard to do in scatterplot3d, because some points should be 
hidden and others shown in front of such a plane, but scatterplot3d has 
no way to do that.  You could do it using the rgl package; the commands 
there would be something like this (without the coloring you did in 
scatterplot3d):

plot3d(x,y,z)
planes3d(0,0,-1,6,col="red")

> 2. Is there a way to color all plotted values with the "z" variate less than the value of 6 one color, and all the rest another color?

In rgl you would do it using

plot3d(x,y,z, col=ifelse(z < 6, "blue", "red"))

I think the same sort of thing works in scatterplot3d, but the arg name 
is color, not col.

Duncan Murdoch


>
> I would greatly apreciate the help on this,
>
> Sincerely,
>
> Andras
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list