[R] add points and labels to a 3 dimensional plot

paladini at trustindata.de paladini at trustindata.de
Fri Mar 28 17:19:28 CET 2014


Thank  you very much!
I used indeed rgl.

The problem was apperently that I used text3d() in the wrong way.



When I use it this way:
plot3d(x, y, z,xlab="PC1", ylab="PC2", zlab="PC3", size=5)
text3d(x=x,y=y,z=z,texts=names, col=4)



It workes the way I wanted.

So thanks again and have a nice weekend!

Best regards

Claudia

Zitat von Duncan Murdoch <murdoch.duncan at gmail.com>:

> On 28/03/2014 6:51 AM, paladini at trustindata.de wrote:
>> Hello,
>> I want to draw  3D plot. The coordinates should  be inticated with a
>> red point  and  additional I want to label them with a name.
>>
>> I tried this:
>>   plot3d(x, y, z,xlab="PC1", ylab="PC2", zlab="PC3",main="Country
>> score resemblance (Stoxx600 rated by
>> Vigeo)",text3d(x=x,y=y,z=z,texts=names, col=4))
>> plot3d(x, y, z, col=2, size=3, add=TRUE)
>
> It looks as though you are using rgl.  If you found plot3d in some  
> other package, then this advice might not apply.
>
> Putting the text3d() call within the plot3d call doesn't make sense.  
>  It should be a separate call.
>
> You should probably use points3d() to add points rather than  
> plot3d(add=TRUE), but there isn't really much difference.
>
> rgl decides what is visible in a fairly complicated way.  The  
> default is that things that are closer to the viewer hide things  
> that are further away, but if two things are at the same distance,  
> the first one wins.  So I would guess that your text is hiding the  
> red points.  It is possible to modify this rule using the  
> material3d() property "depth_test", but I would advise against doing  
> that.
> Plot your text at a different location than your points if you don't  
> want one to obscure the other.  You can use the "adj" parameter to  
> text3d() to offset the text.
>
> Duncan Murdoch
>
>
>>
>> and some variations of this code but in the end you see only the names
>> but no red point.
>>
>> What did I get wrong?
>>
>> It would be nice if somebody can help me.
>>
>> Best regards and thanking you in anticipation
>>
>> Claudia
>>
>> ______________________________________________
>> 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