From maechler at stat.math.ethz.ch  Wed Oct  1 11:24:17 2003
From: maechler at stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Wed Oct  1 10:23:39 2003
Subject: [Rd] colours in dotchart (PR#4343)
Message-ID: <200310010824.h918OH0P026696@pubhealth.ku.dk>

>>>>> "UweL" == Uwe Ligges <ligges@statistik.uni-dortmund.de>
>>>>>     on Mon, 29 Sep 2003 14:36:50 +0200 (MET DST) writes:

    >> i.wilson@maths.abdn.ac.uk wrote:
    >> 
    >> 
    >>> Problem:  neither fg or bg
    >>> nor color work properly in dotchart.
    >>> 
    >>> version:  R-1.7.1 for windows
    >>> 
    >>> code which shows the errors:
    >>> 
    >>> x <-
    >>> 
    >> 
    >> matrix(rnorm(16),ncol=2,dimnames=list(paste("a",1:8,sep=""),c("before","afte
    >> 
    >>> r")))
    >>> dotchart(x,fg="blue",bg="lightgrey")
    >> 
    >> 
    >> That's *not* a bug! It is not documented that *all* graphical parameters
    >> known from par() do work in dotchart() or any other high-level function
    >> (you won't find many!).
    >> 
    >> Instead, use
    >> 
    >> par(fg = "blue", bg = "lightgrey")
    >> dotchart(x)
    >> 
    >> 
    >> 
    >>> dotchart(x,color=c("red","blue"))
    >> 
    >> 
    >> That's *not* a bug! "color" is recycled, but in another way than you
    >> expected.
    >> 
    >> Instead, use
    >> 
    >> dotchart(x, color = rep(c("red", "blue"), each = nrow(x)))
    >> 
    >> 
    >> Please do submit bug reports if you are sure that's a bug. For questions
    >> use the mailinglist r-help, please.
    >> 
    >> 
    >> Uwe Ligges


    UweL> Thanks to Ian Wilson who pointed out in a private
    UweL> message that my first shot was wrong (Sorry!):

less wrong than you say here, excuse but
your first answer was better, Uwe, namely
  >> Instead, use
  >> 
  >> par(fg = "blue", bg = "lightgrey")
  >> dotchart(x)

    UweL> a) Indeed, it is documented that dotchart() supports
    UweL> an argument "bg".  Is it really meant as background
    UweL> colour of the whole plot? 

No! It's not!  It's meant (and used!) as  `bg' argument to
points -- see the lightblue inner color of points in
example(points).  
The only bug here is the `bg' argument documentation in
dotchart.Rd  {well, and the basic design "infelicity" of using
	      "bg" with two different meanings in R graphics ;-)}

    UweL> colour of the whole plot? I's propose to either remove
    UweL> that argument, or implement it to fill the whole
    UweL> background of the plot (as in the proposal below), or
    UweL> document it in a way that tells us it's only expected
    UweL> to fill emtpy plotting characters.

(proposal rejected, see above)


    UweL> b) The argument "color" works for the points, but not so for their 
    UweL> labels. The proposal (by Ian) is to remove the loops. Does that break 
    UweL> anything? At least, I cannot imagine any point right now.

I think you (Ian & Uwe) have a good point here.
This might (or may not) still go as a "trivial bug fix" for 1.8.0.
{If you want to help, please try to use "diff -u" (or "diff -c")
for a patch.. }
But I first need to get my grips on dendrogram buggyness.

Martin


[Rd] colours in dotchart (PR#4343)
maechler@stat.math.ethz.ch