From maechler at stat.math.ethz.ch  Mon Aug 23 16:20:52 2004
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon Aug 23 16:20:59 2004
Subject: [Rd] legend's arguments "angle", "density" & "lwd" (PR#7023)
In-Reply-To: <41263888.2030000@statistik.uni-dortmund.de>
References: <Pine.GSO.3.96.1020313040441.2280B-100000@magic>
	<001e01c1cac5$2ac49960$7632d882@stat.auckland.ac.nz>
	<3C8FB3D0.C7CD3D3D@cancer.org.uk> <3C90045E.C8E0B8C0@icrf.icnet.uk>
	<009b01c1cb92$c7fbdb80$7632d882@stat.auckland.ac.nz>
	<41261239.1030605@statistik.uni-dortmund.de>
	<16678.12628.219394.718403@gargle.gargle.HOWL>
	<41263888.2030000@statistik.uni-dortmund.de>
Message-ID: <16681.64836.177923.532692@gargle.gargle.HOWL>

>>>>> "UweL" == Uwe Ligges <ligges@statistik.uni-dortmund.de>
>>>>>     on Fri, 20 Aug 2004 19:44:40 +0200 writes:

    UweL> Martin Maechler wrote:
    >>>>>>> "UweL" == Uwe Ligges <ligges@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


[Rd] legend's arguments "angle", "density" & "lwd" (PR#7023)
Martin Maechler