[R] axis colors in pairs plot
Deepayan Sarkar
deepayan at stat.wisc.edu
Fri Apr 8 05:26:52 CEST 2005
On Thursday 07 April 2005 17:51, Anne York wrote:
> 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.
One possibility is something along the lines of
pairs(iris[1:4],
panel = function(...)
points(...,
col = c("red", "green3", "blue")
[unclass(iris$Species)] ))
Deepayan
More information about the R-help
mailing list