[R] drawing a specific "plane" with scatterplot3d

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Aug 1 15:58:36 CEST 2012



On 01.08.2012 15:28, Duncan Murdoch wrote:
> On 12-08-01 8:42 AM, Uwe Ligges wrote:
>>
>>
>> On 31.07.2012 21:14, Duncan Murdoch wrote:
>>> 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.
>>
>> No, but the human brain may help to make it not too hard a task:
>>
>> s3d <- scatterplot3d(x[z<6], y[z<6], z[z<6], zlim=range(z),
>>       color="darkgrey", col.axis="blue",col.grid="lightblue",
>>       main="scatterplot3d - 1", pch=20)
>> s3d$plane3d(6, 0, 0)
>> s3d$points3d(x[z>=6], y[z>=6], z[z>=6], pch=20)
>
> Nice solution.  Generally speaking scatterplot3d graphs reproduce better
> than rgl graphs (since they use the regular graphics devices), so it's
> worthwhile using them when you can.

rgl is much better for data analysis, actually: quickly turn the stuff 
around and see what is going on. I'd prefer scatterplot3d only if static 
2D representation is relevant.

Uwe




>
> Duncan Murdoch
>
>>
>> Best,
>> Uwe ligges
>>
>>
>>
>>
>> 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.
>>>>
>>>
>>> ______________________________________________
>>> 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