[R] Multiple colors in plots/lookup function
John Fox
jfox at mcmaster.ca
Thu Oct 17 13:28:42 CEST 2002
Dear David,
At 12:04 AM 10/17/2002 -0400, David Forrest wrote:
> I'd like to do something like:
>
> n<-100
> zz<-cbind(rnorm(n),rnorm(n),floor(runif(n)*3+1))
> colors<-c("red","green","blue")
>
> plot(zz,col=colors(zz[3]))
>
>and have a matrix of scatterplots colored by class. The above does not
>work, of course, but I'm not sure exactly what function I'm looking for.
A couple of people have already mentioned that specifying
col=colors[zz[,3]] will colour the points in a scatterplot (not a
scatterplot matrix) by the values of zz[,3]. Since there are just two other
columns (the third column of zz is ignored in the first argument to plot),
you get a scatterplot, not a scatterplot matrix, and it's hard to see how a
scatterplot matrix would be relevant.
If, however, you want a scatterplot matrix of pairwise plots for three or
more variables coloured by the levels of a factor, the scatterplot.matrix
function in the car package should do what you want.
Regards,
John
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list