[R] Plotting (mixed) line types and legends

Peter Dunn dunn at usq.edu.au
Mon Jul 28 09:00:32 CEST 2003

Hi all

I have a question about plotting line types and
legends.  Here's a short piece of code to

x <- y <- seq(1,10)
plot(x,y, type ="l", lty="33")
lines(x,y+1,  lty=1)
legend( 8,2,legend=c("lty=1","lty=\"33\""), lty=c(1,"33") )

On my system (see below), the line types in the legend
are not the same as in the plot--in particular, lty=1.
(In the plot, the  lty=1  is solid as expected; in the
legend, it is dots close together.)

Is this because I shouldn't mix different ways of defining
line types in the legend?  (ie stick to lty=c(1,2) only, 
for example)?  If so, I couldn't find it documented.

Any explanation appreciated.  If anyone know hows to
do such a thing (ie define different line types in the
legend), I'd love to hear.  (And yes, I need to do it--the
example above was a short snippet that just demos the problem.)


My system:

> version
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
major    1
minor    7.0
year     2003
month    04
day      16
language R

Dr Peter Dunn          (USQ CRICOS No. 00244B)
  Web:    http://www.sci.usq.edu.au/staff/dunn
  Email:  dunn @ usq.edu.au
Opinions expressed are mine, not those of USQ.  Obviously...

More information about the R-help mailing list