[R] barplot default colors

Liaw, Andy andy_liaw at merck.com
Wed Feb 5 18:02:03 CET 2003

> From: Thomas Lumley [mailto:tlumley at u.washington.edu]
> On Wed, 5 Feb 2003, Liaw, Andy wrote:
> > Can some one explain why barplot() uses changing colors in 
> the bars by
> > default?  I should think that most of the time when people 
> draw barplots,
> > they want the bars to be in the same color.  (At least 
> that's what I'd
> > expect.  The first time I used barplot() in R, I was 
> shocked to see the
> > colors.)  As an example, one example in ?layout draws a 
> scatterplot with
> > histograms drawn on the margins.  The histograms were drawn 
> by barplot(),
> > and, IMHO, look rather hideous in the colors.
> The changing colours are useful when the data are a matrix 
> (so that you
> have bars either stacked or in groups).  You can easily get a single
> color,
> eg
> data(VADeaths)
> barplot(VADeaths, beside=TRUE, col="thistle")

In that case, couldn't the code check whether the input is a matrix, and
only use the changing colors if it is, and use only one color if the input
is a vector (w/o dimensions)?  Getting all bars to have the same color is
easy.  My gripe is that it's not the default, which surprised me.  

In the danger of taking this a bit off-topic, are there any "guidelines" on
what aspect of R should and should not be compatible with Splus?  barplot()
in Splus does not use varying colors for the bars by default.  Meanwhile,
lattice uses the gray background / light blue foreground theme from Trellis
as default, for the supposed compatibility with Splus.  Personally I hated
that color-scheme (because of my poor eye-sight and colorblind), but thought
that compatibility with S is a rather weak reason there...

OK, I guess enough venting for the day...




More information about the R-help mailing list