Skip to content

Question regarding legend look

6 messages · David Winsemius, Duncan Murdoch, Philippe Massicotte

#
Hi everyone.

I have a quick question regarding the look of my legend in my plot. As you
can see in the next figure, I have 3 series.

http://r.789695.n4.nabble.com/file/n3067466/legend.png 


However, I find rather difficult to differentiate the series 1 and 3
according to their line type (lty). I would like to know if it was possible
to make the line type in the legend to appear more clearly. For example, to
give more horizontal space each side of the symbols "square" to have a
better idea of the line type.

With regards,
Phil
#
On Dec 1, 2010, at 10:13 AM, Filoche wrote:

            
The specifics will depend on what plotting function produced the graph  
from which you have given us a bitmap snapshot BUT NOT SHOWN US CODE  
OR SAMPLE DATA. In xyplot you would be working with the key/lines/size  
elements (after showing us which of the several legend options were  
specified):

?xyplot

In base graphics I do not see a "handle" on the line length but  
(perhaps) you could emphasize the line compenent by increasing cex  
which affects all components and at the same time decrease the point  
size. E.g.:

  legend( ..., cex=1.5, pt.cex=0.8, cex=1.5, pt.cex=0.8, ...)

As always____>
__ ___________________________________

David Winsemius, MD
West Hartford, CT
#
On Dec 1, 2010, at 11:51 AM, David Winsemius wrote:

            
snipped
At one point that said:
   legend( ..., merge=TRUE, cex=1.5, pt.cex=0.8, ...)
David Winsemius, MD
West Hartford, CT
#
David Winsemius wrote:
Hi and thank you for your help.

For instance, here's my code:

legend("topleft", inset = .05, title="Water masses", pch = c(22,25,21), lty
= c(4,1,2), lwd = 1, c("North","Central","South"), horiz = F, pt.bg
=c("gray43","gray0","gray86"), cex = 1, bg = "white");
#
On 01/12/2010 10:13 AM, Filoche wrote:
There is no parameter to the legend function to control this, but it is 
pure R code, so you could write your own by modifying the legend() function.

If you take a look at legend, you'll see that it draws lines of length 2 
(in some units) when do.lines is TRUE.  Change that to a bigger number, 
and you'll get longer lines.  You'll also need to fiddle with the size 
of the box, or the legend won't fit.  (I think xbox is the variable 
holding its width.)

Duncan Murdoch