[Rd] legend's arguments "angle", "density" & "lwd" (PR#7023)
Martin Maechler
maechler at stat.math.ethz.ch
Mon Aug 23 16:20:52 CEST 2004
>>>>> "UweL" == Uwe Ligges <ligges at statistik.uni-dortmund.de>
>>>>> on Fri, 20 Aug 2004 19:44:40 +0200 writes:
UweL> Martin Maechler wrote:
>>>>>>> "UweL" == Uwe Ligges <ligges at statistik.uni-dortmund.de>
>>>>>>> on Fri, 20 Aug 2004 17:01:13 +0200 writes:
>>
UweL> Paul Murrell wrote [on 2002-03-14 with Subject: "filled bars with
UweL> patterns" in reply to Arne Mueller]
>>
>> >> Hi
>> >>
>> >> <snip>
>> >>
>> >>> I'd also like to have the filled boxes in the legend to be striped. The
>> >>> legend function has a 'density' attribute, but unfortunately this does't
>> >>> seem to do anything
>> >>>
>> >>> following the above example
>> >>>
>> >>> legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), fill = c('red', 'blue',
>> >>> 'green', 'orange'))
>> >>>
>> >>> is the same as
>> >>>
>> >>> legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), density=10,
>> >>> fill = c('red', 'blue', 'green', 'orange'),
>> >>> density=c(10,-1,20, 200))
>> >> This appears to be a bug. Can you file a bug report for this please?
UweL> [SNIP; I cannot find any related bug report in the repository]
UweL> I'm just reviewing bug reports and other stuff re. legend() and found
UweL> this old message in one of my Next-Week-To-Do-folders.
>>
UweL> Well, the point mentioned above is not really a bug,
UweL> because one has to specify BOTH arguments, angle AND
UweL> density in legend(). Is there any point not to make
UweL> angle = 45 the default, as it already is for polygon()
UweL> and rect()?
MM> This seems like a good idea,
MM> but we'll wait for your many other patches to legend.R and
MM> legend.Rd :-)
UweL> Just three rather than many issues I'm trying to address, the third one
UweL> is just closing a bug report. ;-)
UweL> Here the two suggested patches in merged form.
UweL> Uwe
<........... snipping Uwe's patches .........>
This has now lead to more:
I've just added to NEWS (and the C and R sources of course)
o plot.xy(), the workhorse function of points, lines and plot.default
now has 'lwd' as explicit argument instead of implicitly in "...",
and now recycles lwd where it makes sense, i.e. for line based plot
symbols.
such that Uwe's proposed new argument to legend(), pt.lwd is
also recycled and now can default to 'lwd', the line width of
the line segments in legend().
Hence, Leslie's original feature request (PR#7023) of June 25
is now also fulfilled using only 'lwd' and not both 'lwd' and 'pt.lwd'.
I.e., the following now works
x <- 1:10 ; y <- rnorm(10,10,5) ; y2 <- rnorm(10,8,4)
plot(x, y, bty="l", lwd=3, type="o", col=2, ylim = range(y,y2), cex=1.5)
points(x, y2, lwd=3, lty=8, col=4, type="o", pch=2, cex=1.5)
legend(10, max(y, y2), legend=c("Method 1","Method 2"),
col=c(2, 4), lty=c(1, 8), pch=c(1, 2),
xjust=1, yjust=1, pt.cex=1.5, lwd=3)
[note that I've used 'ylim = range(y,y2)' which is slightly better than
'ylim = c(min(y,y2),max(y,y2))']
With thanks to Uwe!
Martin
More information about the R-devel
mailing list