# [R] legend with filled boxes AND lines

Martin Maechler maechler at stat.math.ethz.ch
Mon Jul 3 18:41:54 CEST 2006

```Did you try  legend(......, lty=..., fill=...,  merge = TRUE) ?

In an example I just tried, this allowed to give filled boxes
*and* lines.

Please give a reproducible example of what you did -- maybe by
modifying one of the many  example(legend)  examples.

Martin Maechler, ETH Zurich

>>>>> "florian" == florian koller <florian.koller at gfk.com>
>>>>>     on Mon, 3 Jul 2006 13:40:33 +0200 writes:

florian> Dear all,

florian> Is there a straightforward way to create a legend
florian> box that has both filled boxes and lines?  So far I
florian> have built around this problem by creating two
florian> legends (with bty = "n") and manually drawing a box
florian> around both (but this is cumbersome, because I have
florian> to check upon the y coordinates of the legends
florian> every time).

florian> If I do something like > legend( ...,c("X1","X2",
florian> "mean"), fill = c("red", "blue", 0), lty = (0,0,2))
florian> < , I cannot get rid of the unfilled box or change
florian> the color of the fill box border (from its default
florian> color "black"), and I end up with two filled boxes
florian> and an empty, black-lined box plus the line as a
florian> legend for the third argument "mean". This trick
florian> therefore only works if I define "black" as the bg
florian> color for the complete legend box (because it masks
florian> the empty box from the fill argument). So, if there
florian> is a command to modify the color of the fill box
florian> border line (not the legend box border line), this
florian> would help me, too (still not ideal, though...).

florian> Thanks,
florian> Florian

florian> ______________________
florian> Florian Koller
florian> GfK Fernsehforschung GmbH
florian> Research Consulting & Development
florian> Nordwestring 101
florian> D-90319 Nürnberg
florian> Fon  +49 (0)911 395-3554
florian> Fax  +49 (0)911 395-4130
florian> www.gfk.de / www.gfk.com

florian> _________________________

florian> Diese E-Mail (ggf. nebst Anhang) enthält vertrauliche und/oder rechtlich
florian> geschützte Informationen. Wenn Sie nicht der richtige Adressat sind, oder
florian> diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
florian> Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die
florian> unbefugte Weitergabe dieser Mail ist nicht gestattet.

florian> This e-mail (and any attachment/s) contains confidential and/or privileged
florian> information. If you are not the intended recipient (or have received this
florian> e-mail in error) please notify the sender immediately and destroy this
florian> e-mail. Any unauthorised copying, disclosure or distribution of the
florian> material in this e-mail is strictly forbidden.

florian> ______________________________________________
florian> R-help at stat.math.ethz.ch mailing list
florian> https://stat.ethz.ch/mailman/listinfo/r-help