Skip to content
Prev 21991 / 63424 Next

Legend frame error (PR#9236)

tgibson at augustcouncil.com writes:
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.