RE: [R] axis colors in pairs plot

From: <Bill.Venables_at_csiro.au>
Date: Fri 08 Apr 2005 - 13:40:17 EST


Hi Anne,

Here's one suggestion, use a simple panel function:

cols <- c("red", "green3", "blue")

with(iris,
  pairs(iris[, -5], main = "Andersons Iris Data - 3 species",   panel = function(x, y, ...)

          points(x, y, pch = (2:4)[Species], col = cols[Species], ...)   ))  

Bill Venables

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Anne York Sent: Friday, 8 April 2005 8:51 AM
To: Help R
Subject: [R] axis colors in pairs plot

The following command produces red axis line in a pairs plot:

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species", pch = "+", col = c("red", "green3", "blue")[unclass(iris$Species)])

Trying to fool pairs in the following way produces the same plot as above:

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",pch = "+", col = c("black", "red", "green3", "blue")[ 1+ unclass(iris$Species)])

One very kludgy work-around is to define a new level 1, say "foo" in the first row of iris:

iris2=iris

iris2$Species = as.character(iris2$Species)
iris2$Species[1]="foo"
iris2$Species = factor(iris2$Species)

pairs(iris2[1:4], main = "Anderson's Iris Data -- 3 species", pch = "+",
col = c( "black","red", "green3","blue")[ unclass(iris2$Species)])

However, if any other row is redefined, the red-axis persists. For example:

iris2=iris

iris2$Species = as.character(iris2$Species)
iris2$Species[3]="foo"
iris2$Species = factor(iris2$Species)


pairs(iris2[1:4], main = "Anderson's Iris Data -- 3 species", pch = "+",
col = c( "black","red", "green3","blue")[ unclass(iris2$Species)])

I'd appreciate suggestions for a simpler work-around.

Thanks,
Anne



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Apr 08 13:45:07 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:05 EST