Hello, 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. Thank you for your time, Dave, -- Dave Forrest (434)924-3954w(111B) (804)642-0662h (804)695-2026p drf5n at virginia.edu http://mug.sys.virginia.edu/~drf5n/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, Oct 17, 2002 at 12:04:17AM -0400, David Forrest wrote:> Hello, > 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]))if you replace the last line by plot(zz,col=colors[zz[, 3]]) it seems to work. Hopin' it helps, L.> > 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. > > Thank you for your time, > Dave, > -- > Dave Forrest (434)924-3954w(111B) (804)642-0662h (804)695-2026p > drf5n at virginia.edu http://mug.sys.virginia.edu/~drf5n/ > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- -------------------------------------------------------------- Laurent Gautier CBS, Building 208, DTU PhD. Student DK-2800 Lyngby,Denmark tel: +45 45 25 24 89 http://www.cbs.dtu.dk/laurent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 17-Oct-2002 David Forrest wrote:> Hello, > 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]))but this does: plot(zz, col=colors[zz[,3]]) detlef> > 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. > > Thank you for your time, > Dave, > -- > Dave Forrest (434)924-3954w(111B) (804)642-0662h (804)695-2026p > drf5n at virginia.edu http://mug.sys.virginia.edu/~drf5n/ > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > - > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _"There is no way to peace, peace is the way." -- Ghandi Detlef Steuer --- http://fawn.unibw-hamburg.de/steuer.html ***** Encrypted mail preferred ***** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Hello, > 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. >Dave, Not quite sure what you are after. Are you wanting to plot n vs zz for each column of zz?. If so try this... n <- 100 zz <- cbind(rnorm(n),rnorm(n),floor(runif(n)*3+1)) colors<-c("red","green","blue") for(i in 1:3){ plot(1:n,zz[,i],col=colors[i],ylim=range(zz)) par(new=T) } or a pairs type plot. In which case something like this will do (not sure what you mean about the colours in this case) par(mfrow=c(3,3)) for(i in 1:3){ for(j in 1:3){ plot(zz[,i],zz[,j],col=colors[i],ylim=range(zz), xlim=range(zz)) } } Richard -- Dr. Richard Nixon MRC Biostatistics Unit, Cambridge, UK http://www.mrc-bsu.cam.ac.uk/personal/richard Tel: +44 (0)1223 330382, Fax: +44 (0)1223 33038 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._