[R] plot3d with more than 8 colors

Birgit Lemcke birgit.lemcke at systbot.uzh.ch
Mon Oct 22 17:26:13 CEST 2007


Am 22.10.2007 um 17:19 schrieb Duncan Murdoch:

> On 10/22/2007 9:54 AM, Birgit Lemcke wrote:
>> Hello R user and helper!
>> I would like to get a 3d plot with coloured points.
>> I did that:
>> colors<-c(rep("2",7), rep("3",12), rep("4", 24), rep("5", 13), rep  
>> ("6", 8), rep("7", 51), rep("8", 1), rep("9", 15), rep("10", 53),  
>> rep ("11",3), rep("12",3), rep("13", 8), rep("14", 90), rep("15",  
>> 8), rep ("16", 9), rep("17", 32), rep("18",11))
>> PCoA<-cmdscale(Dist.Gower, k = 3)
>> plot3d(PCoA, type="s",col= colors, size=0.5)
>
> plot3d is not in base R.  There are several contributed packages  
> that have functions with that name:  rgl, compositions, etc.   
> Saying which one you want might help.
>
Sorry I use plot3d from rgl.

> However, in general colours in R can be specified as character  
> strings giving names or RGB levels, so you could probably use  
> those.  Something  like terrain.colors(n) will give you a vector of  
> n different colors, and its man page has lots of other colour  
> sequences and links to other ways of creating colours.

Thanks terrain.colors is exactly what I need.
>
>> but I get only different colors for the numbers 1 to 8 and after  
>> that  it starts again with the first colour black.
>> How can get more different colours?
>> And two further questions: how can I ad a legend to the 3d-plot  
>> and  is there now a possibility to export movable 3d files?
>
> That depends on the package.  rgl currently has no legend  
> capability. It can export movies, but not anything the user could  
> control.  Both of those would be nice additions, but both are  
> fairly hard work, so they probably won't come very soon.

Thanks for your help

Birgit

>
> Duncan Murdoch
>
>> Thanks in advance for your help.
>> Greetings
>> Birgit
>> Birgit Lemcke
>> Institut für Systematische Botanik
>> Zollikerstrasse 107
>> CH-8008 Zürich
>> Switzerland
>> Ph: +41 (0)44 634 8351
>> birgit.lemcke at systbot.uzh.ch
>> ______________________________________________
>> 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.
>

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
birgit.lemcke at systbot.uzh.ch



More information about the R-help mailing list