From ripley@stats.ox.ac.uk  Sat Nov 23 09:52:07 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Sat, 23 Nov 2002 09:52:07 +0000 (GMT)
Subject: [Rd] Small change to plot.xy
In-Reply-To: <3DDF4568.63CB31D1@durham.ac.uk>
Message-ID: <Pine.LNX.4.31.0211230946500.4803-100000@gannet.stats>

On Sat, 23 Nov 2002, Jonathan Rougier wrote:

> OK -- so there are two objections to the proposal:
>
> 1) The factor might be a colour specifier
>
> 2) Using codes is not a good idea because there are only 8 colours
> available for an integer argument to col.

You seem not to appreciate

0) You used codes when you should have used unclass!

which was made twice.  Please do make sure you understand the difference.

> I can see that both of these have merit, but I think they are both easy
> to work around, if necessary.  No-one has disagreed that it's natural to
> want to pass a factor to col, and I believe that the vast majority of
> times when this occurs the factor is not designed explicitly to paint
> the points.

I did disagree.  I don't see why users should not explicitly map the
factor levels to colours, which takes only a few extra characters.
People have been doing this for a decade in S without objecting.
Why is it worth complicating R for?

> I think I would let the first objection pass.  Using codes to coerce the
> factor we still get different colours for different factors, just not
> the specified colours.  This is not right, but it's rarely a disaster
> either and should be easy to spot for anyone who is expecting to see
> "slateblue" and gets "red".
>
> As for the second objection, I think this is valid and should be
> addressed, but at the same time it is a different problem.  I often
> wondered why col = 1 was black (not really a colour at all, and not very
> good for boxplots) and, more pertinently, why col = 2 is red and col = 3
> is green: isn't the most common form of colour-blindness red/green?  At
> the very least, let's not have them next to each other in the list!  We
> have 657 named colours to choose from: why not have a explicit "int2col"
> function that provides a bigger and better table?

Not all devices (by any means) can display those colours, or only a
limited number of colours in total.

> More-or-less the same arguments also apply to pch.
>
> Jonathan.
>
> Jonathan Rougier wrote:
> >
> > Hi everyone,
> >
> > Is there any reason why we should not automatically coerce a factor
> > supplied as an argument to col in a plotting function?  The following
> > modification (to R-1.6.1) seems pretty harmless
> >
> > > plot.xy
> > function (xy, type, pch = 1, lty = "solid", col = par("fg"),
> >     bg = NA, cex = 1, ...)
> > {
> >     if (is.factor(col))
> >         col <- codes(col)
> >     .Internal(plot.xy(xy, type, pch, lty, col, bg, cex, ...))
> > }
> > <environment: namespace:base>
> >
> > and I think it is natural and not really wrong to want to type, say,
> >
> > > data(iris)
> > > pairs(iris[, 1:4], col = iris[, 5])
> >
> > and get the colours.
> >
> > Cheers, Jonathan.
> >
> > --
> > Jonathan Rougier                       Science Laboratories
> > Department of Mathematical Sciences    South Road
> > University of Durham                   Durham DH1 3LE
> > tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
> > http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
> >
> > ______________________________________________
> > R-devel@stat.math.ethz.ch mailing list
> > http://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
> --
> Jonathan Rougier                       Science Laboratories
> Department of Mathematical Sciences    South Road
> University of Durham                   Durham DH1 3LE
> tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
> http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
>
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Small change to plot.xy
ripley@stats.ox.ac.uk