[R] Legend Line Size
McGehee, Robert
Robert.McGehee at geodecapital.com
Mon Mar 14 21:55:55 CET 2005
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)
Thanks,
Robert
More information about the R-help
mailing list