[R] legend in R plot

Peter Ehlers ehlers at ucalgary.ca
Thu Jul 22 10:36:32 CEST 2010


On 2010-07-21 22:06, li li wrote:
> Hi all,
>    I am have some difficulty with the legend function.
>    I need to add a legend to describe the different line types in a plot. The
> legend box is small.
> It did not include sufficient length of each line type to help distinguish
> the differnt line types.
>    Is there a way to fix this.
>    Thank you
>                               Hannah
>

If I understand correctly, you want to have longer
line segments in your legend. I agree that this is
sometimes desirable but, with the current code,
it's not possible - the segment length is hard-coded.

If it matters enough to you, you can easily modify the
code to achieve your aim: search for the following two
lines and in each replace the '2' with a greater value,
say '3'.

First line:

             w0 <- w0 + (2 + x.off) * xchar

Second line:

         seg.len <- 2

I don't think that this will have any undesirable side
effects, but I haven't given it much thought. I haven't
had any problems with this version of legend().

   -Peter Ehlers



More information about the R-help mailing list