[R] Legend Line Size

From: McGehee, Robert <Robert.McGehee_at_geodecapital.com>
Date: Tue 15 Mar 2005 - 07:55:55 EST

Hello all,

When I view or print the below plot on my Linux machine under R 2.0.1 I see a nice thick solid and dashed line with a legend. However, while the lines are distinguishable, the legend is not. That is, the short (solid) line next to "line1" and the short (dashed) line next to "line2" seem to have the exact same length. What I would like to do is to expand the legend line a bit farther so that the user can clearly see a solid vs. a dashed line and not too small lines that look the same.

A glance at the legend source code shows that the line segment length (seg.len) seems to be hard-coded as 2. If I change this to a larger number within the code, I get the effect that I want (although the box around the legend needs to be resized). Am I overlooking a more obvious way to distinguish the legend lines, or would it make more sense to patch the legend function to fit my needs?

x <- 1:10
plot(x, x, type = "l", lty = 1, lwd = 4) lines(x, 2*x, type = "l", lty = 5, lwd = 4) legend(7, 5, legend = c("line1", "line2"), lty = c(1, 5), lwd = 4)


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Mar 15 08:00:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:47 EST