Skip to content

legend lwd - feature request (PR#7023)

1 message · Uwe Ligges

#
Lfo@psykiatri.aaa.dk wrote:

            
The quick patch at the end of this message will add an argument pt.lwd 
to legend(). Note that this argument only accepts one value for all 
point, because vectorized widths are not supported by points() and friends.

There is another point to consider for the long term:
In order to restrict the possibly huge amount of possible values for 
legend() and make it legend() more flexible (I know, it already is very 
flexible), one might want to invent new arguments like point.args, 
line.args, text.args that accept lists of arguments to be passed to the 
corresponding underlying functions. However, that would require a 
redesign of legend() - and would certainly break some code ...

Uwe Ligges


Patch, diff'ed against r-devel (rev. 30796):


--- y:\recent\R\src\library\graphics\R\legend.R
+++ legend.R    2004-08-20 15:08:13.000000000 +0200
@@ -1,7 +1,7 @@
  legend <-
  function(x, y = NULL, legend, fill=NULL, col = "black", lty, lwd, pch,
-     angle = NULL, density = NULL, bty = "o",
-     bg = par("bg"), pt.bg = NA, cex = 1, pt.cex = cex,
+     angle = NULL, density = NULL, bty = "o", bg = par("bg"),
+     pt.bg = NA, cex = 1, pt.cex = cex, pt.lwd = par("lwd"),
       xjust = 0, yjust = 1, x.intersp = 1, y.intersp = 1, adj = c(0, 0.5),
       text.width = NULL, text.col = par("col"),
           merge = do.lines && has.pch, trace = FALSE,
@@ -178,8 +178,8 @@
      if(trace)
          catn("  points2(", x1,",", y1,", pch=", pch[ok],", ...)")
      if(plot)
-        points2(x1, y1,
-                    pch = pch[ok], col= col[ok], cex= pt.cex[ok], bg= 
pt.bg[ok])
+        points2(x1, y1, pch = pch[ok], col = col[ok], cex = pt.cex[ok],
+                bg = pt.bg[ok], lwd = pt.lwd)
      if (!merge) xt <- xt + dx.pch
      }



--- y:\recent\R\src\library\graphics\man\legend.Rd
+++ legend.Rd   2004-08-20 15:13:41.000000000 +0200
@@ -4,8 +4,8 @@
  \usage{
  legend(x, y = NULL, legend, fill = NULL, col = "black", lty, lwd, pch,
         angle = NULL, density = NULL, bty = "o", bg = par("bg"),
-       pt.bg = NA, cex = 1, pt.cex = cex, xjust = 0, yjust = 1,
-       x.intersp = 1, y.intersp = 1, adj = c(0, 0.5),
+       pt.bg = NA, cex = 1, pt.cex = cex, pt.lwd = par("lwd"), xjust = 0,
+       yjust = 1, x.intersp = 1, y.intersp = 1, adj = c(0, 0.5),
         text.width = NULL, text.col = par("col"),
         merge = do.lines && has.pch, trace = FALSE,
         plot = TRUE, ncol = 1, horiz = FALSE)
@@ -43,6 +43,7 @@
    \item{cex}{character expansion factor \bold{relative} to current
      \code{par("cex")}.}
    \item{pt.cex}{expansion factor(s) for the points.}
+  \item{pt.lwd}{line width for the points.}
    \item{xjust}{how the legend is to be justified relative to the legend
      x location.  A value of 0 means left justified, 0.5 means centered
      and 1 means right justified.}