[Rd] A small bug in R code of the legend function of the	Graphics pacakge (PR#13340)
    maechler at stat.math.ethz.ch 
    maechler at stat.math.ethz.ch
       
    Sat Nov 29 18:10:08 CET 2008
    
    
  
>>>>> "ASh" == asherman  <asherman at ksu.ru>
>>>>>     on Thu, 27 Nov 2008 14:30:04 +0100 (CET) writes:
    ASh> Full_Name: Arkady  Sherman
    ASh> Version: 2.8.0
    ASh> OS: Windows XP
    ASh> Submission from: (NULL) (158.195.16.114)
    ASh> Please consider initialization of the "seg.len"
    ASh> variable. It's done only
    ASh> if (do.lines) {  seg.len <- 2 ..,
    ASh> but after the seg.len is used:
    ASh> if (has.pch) {
    ASh> pch <- rep(pch, length.out = n.leg)
    ASh> pt.bg <- rep(pt.bg, length.out = n.leg)
    ASh> pt.cex <- rep(pt.cex, length.out = n.leg)
    ASh> pt.lwd <- rep(pt.lwd, length.out = n.leg)
    ASh> ok <- !is.na(pch) & (is.character(pch) | pch >= 0)
    ASh> x1 <- (if (merge) 
    ASh> xt - (seg.len/2) * xchar
    ASh> so if do.lines isn't specified, but has.pch and merge are specified an error is
    ASh> produced.
but do.lines is never specified.  It can be FALSE (if there are no
lines drawn) and a user can indeed set 'merge = TRUE" in such a
situation.
However, can you think of a situation where this was desirable?
I think it should not have any effect in such a case
{... but unfortunately it currently has ... yet another
     sign that legend() is ``hopelessly over-featured'' ;-) }
and possibly rather give a warning in such a case...
    ASh> Guess that seg.len should be initialized before the condition "if (do.lines)"
not really; it means  'segment length' should not be used unless
segments ("lines") are drawn.
Thank you for your note;  you are right that legend() is not
entirely correct in such a border-line situation.
Regards,
Martin Maechler, ETH Zurich
    
    
More information about the R-devel
mailing list