Re: [R] axis colors in pairs plot

From: Anne York <york_at_zipcon.net>
Date: Fri 08 Apr 2005 - 22:53:28 EST

Thanks Bill and Deepayan for the panel function idea.

Somehow I've always associated the panel functions with lattice -- not sure why, but thanks for pointing out their more universal applicability.

Anne
On Thu, 7 Apr 2005, Deepayan Sarkar wrote:

DS > On Thursday 07 April 2005 17:51, Anne York wrote:
DS > > The following command produces red axis line in a pairs
DS > > plot:
DS > >
DS > > pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
DS > > pch = "+", col = c("red", "green3",  "blue")[unclass(iris$Species)])
DS > >
DS > >
DS > > Trying to fool pairs in the following  way  produces the
DS > > same plot as above:
DS > >
DS > > pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",pch =
DS > > "+", col = c("black", "red", "green3", "blue")[ 1+
DS > > unclass(iris$Species)])
DS > >
DS > > One very kludgy work-around is to define a new level 1, say
DS > > "foo" in the first row of iris:
DS > >
DS > > iris2=iris
DS > > iris2$Species = as.character(iris2$Species)
DS > > iris2$Species[1]="foo"
DS > > iris2$Species = factor(iris2$Species)
DS > >
DS > > pairs(iris2[1:4], main = "Anderson's Iris Data -- 3
DS > > species", pch = "+",
DS > > col = c( "black","red", "green3","blue")[ unclass(iris2$Species)])
DS > >
DS > > However, if any other row is redefined, the red-axis
DS > > persists. For example:
DS > >
DS > > iris2=iris
DS > > iris2$Species = as.character(iris2$Species)
DS > > iris2$Species[3]="foo"
DS > > iris2$Species = factor(iris2$Species)
DS > >
DS > >
DS > > pairs(iris2[1:4], main = "Anderson's Iris Data -- 3
DS > > species", pch = "+",
DS > > col = c( "black","red", "green3","blue")[ unclass(iris2$Species)])
DS > >
DS > > I'd appreciate suggestions for a simpler work-around.
DS > 
DS > One possibility is something along the lines of
DS > 
DS > pairs(iris[1:4], 
DS >       panel = function(...)
DS >           points(..., 
DS >                  col = c("red", "green3", "blue")
DS >                          [unclass(iris$Species)]  ))
DS > 
DS > Deepayan
DS > 
DS >

______________________________________________
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 Sat Apr 09 02:00:23 2005

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