Hi list, not sure if this is the wanted behavior, but running the following code:> versionplatform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 1.1 year 2005 month 06 day 20 language R> n <- 500 > d <- 4 > m <- matrix(runif(n*d, -1, 1), ncol=d) > c <- hsv(apply(m, 1, function(x) {sum(x*x)/d}), 1, 1) > pairs(m, col=c)gives me the desired coloring of the points but also colors the axes. Looking at the source for pairs() suggests, that this is the case because col is part of the ... argument list which is passed on to localAxis (and from there to axis). Wouldn't it be more approptiate to use the same color box() uses to draw the border around each scatterplot? If yes, should I open a bug for this or how would such a feature request be handled? -- Olaf Mersmann
Olaf Mersmann wrote:> Hi list, > > not sure if this is the wanted behavior, but running the following code:I'd say it's a bug.> > >>version > > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 1.1 > year 2005 > month 06 > day 20 > language R > >>n <- 500 >>d <- 4 >>m <- matrix(runif(n*d, -1, 1), ncol=d) >>c <- hsv(apply(m, 1, function(x) {sum(x*x)/d}), 1, 1) >>pairs(m, col=c) > > > gives me the desired coloring of the points but also colors the axes. > Looking at the source for pairs() suggests, that this is the case > because col is part of the ... argument list which is passed on to > localAxis (and from there to axis). Wouldn't it be more approptiate to > use the same color box() uses to draw the border around each > scatterplot? If yes, should I open a bug for this or how would such a > feature request be handled?The best way is to get the source to pairs() (from the SVN repository in https://svn.r-project.org/R/trunk/src/library/graphics/R/pairs.R not from looking at it in R), work out what changes are needed, and submit them as a patch. You can post the patch in the R-bugs list, or just send it to me. Thanks! Duncan Murdoch
On 7/8/2005 8:52 AM, Olaf Mersmann wrote:> Hi Duncan, > > On 7/8/05, Duncan Murdoch <murdoch at stats.uwo.ca> wrote: >> Olaf Mersmann wrote: > *snip* >> > Looking at the source for pairs() suggests, that this is the case >> > because col is part of the ... argument list which is passed on to >> > localAxis (and from there to axis). Wouldn't it be more approptiate to >> > use the same color box() uses to draw the border around each >> > scatterplot? If yes, should I open a bug for this or how would such a >> > feature request be handled? >> >> The best way is to get the source to pairs() (from the SVN repository >> in https://svn.r-project.org/R/trunk/src/library/graphics/R/pairs.R not >> from looking at it in R), work out what changes are needed, and submit >> them as a patch. You can post the patch in the R-bugs list, or just >> send it to me. Thanks! > > I attached my patch to pairs.R to fix the problem. They way I 'solved' > the issue is by simply ignoring any col argument that is passed to > localAxis and from there to axis. At first I had thought about adding > col explicitly to the argument list of pairs() and then only passing > it on to the panel functions, but that would possibly break existing > code (for example the example panel.cor() in the pairs() man page).I like your fix. It makes pairs() act like plot() in its treatment of col and col.axis parameters. I do find the col.axis treatment a little weird (affecting the labels, but not the axis), but that's a different issue. I'll commit your patch to R-devel and R-patched. Duncan Murdoch
A work-around for this problem was posted on April 7 by Bill Venables and Deepayan Sarkar using a panel function: 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")[ nclass(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 > On Fri, 8 Jul 2005, Olaf Mersmann wrote: OM > Hi list, OM > OM > not sure if this is the wanted behavior, but running the following code: OM > OM > > version OM > platform i386-pc-mingw32 OM > arch i386 OM > os mingw32 OM > system i386, mingw32 OM > status OM > major 2 OM > minor 1.1 OM > year 2005 OM > month 06 OM > day 20 OM > language R OM > > n <- 500 OM > > d <- 4 OM > > m <- matrix(runif(n*d, -1, 1), ncol=d) OM > > c <- hsv(apply(m, 1, function(x) {sum(x*x)/d}), 1, 1) OM > > pairs(m, col=c) OM > OM > gives me the desired coloring of the points but also colors the axes. OM > Looking at the source for pairs() suggests, that this is the case OM > because col is part of the ... argument list which is passed on to OM > localAxis (and from there to axis). Wouldn't it be more approptiate to OM > use the same color box() uses to draw the border around each OM > scatterplot? If yes, should I open a bug for this or how would such a OM > feature request be handled? OM > OM > -- Olaf Mersmann OM > OM > ______________________________________________ OM > R-help at stat.math.ethz.ch mailing list OM > https://stat.ethz.ch/mailman/listinfo/r-help OM > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html OM > OM >