Re: [Rd] Legend frame error (PR#9236)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 18 Sep 2006 - 20:43:40 GMT

tgibson@augustcouncil.com writes:

> Hello,
> The frame drawn around the legend appears to miscalculate when the
> x-axis decreases rather than increases. Pasted below is a simple
> testcase. When the x-axis decreases, the width of the legend frame
> appears to be calculated based on the length of the first item, rather
> than the maximum length of all items.

More likely, it is calculating the maximum of the endpoints, which will of course be the one furthest to the left if the x axis is reversed. (As reordering the legends would have shown you.)

The construction

    if (is.null(text.width))

        text.width <- max(strwidth(legend, units = "user", cex = cex))     else if (!is.numeric(text.width) || text.width < 0)

        stop("'text.width' must be numeric, >= 0")

seems to be the culprit. max() should be min() in the reversed case.

And if I'm not mistaken, there's an additional issue: If the x axis is reversed, an explicit text.width setting should in fact be negative.

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue Sep 19 06:48:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 18 Sep 2006 - 22:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.