[R] scatterplot3d using colors in groups

Duncan Mackay mackay at northnet.com.au
Wed May 4 02:37:29 CEST 2011


At 10:15 04/05/2011, you wrote:
>Content-Type: text/plain
>Content-Disposition: inline
>Content-length: 537
>
>Hi everyone,
>
>I would like to improve my plot and I was 
>wondering if someone can help me whith it. I'm 
>trying this plot using two groups, but I want to 
>choice the colors (the black and white circles) 
>but I don't know how to change it from here. These are my sentences:
>
>myplot3d<- scatterplot3d(myfile$Temperature,
>acantarcthus$Salinity,myfile$Abundance, type="h",
>    color = as.integer(factor(myfile$groups)))
>
>If someone is willing to help me with it I would be so glad.
>
>José
>
>         [[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.

Hi José

Have you seen the result of 
as.integer(factor(myfile$groups))) ? I would have given you a clue.

What you need is c("black","white") or the 
numerical col number equivalent by the order of the groups.

2 ways:

ifelse(myfile$groups == factor1, "black","white")

or if you had more factors

sapply(myfile$groups, pmatch, unique(myfile$groups) )

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home mackay at northnet.com.au



More information about the R-help mailing list