[R] Making legend() look like my plot()

Dan Bolser
Thu, 25 Nov 2004 14:01:54 -0000

Hello,

I am using code like the following to create as simple plot...



plot(x,y,type='b')
lines(lowess(x,y),lwd=3,lty=3,col=2)

I want to add a legend which shows lines looking exactly like those used
in my plot, i.e. a thin black line with gaps taken up by circles (the
default for type='b', and a thick dashed red line with no pch at all).

I have two problems,

1) making the pch on the first like look like type = 'b' (gaps around
pch)
2) surpressing a pch on for the second line


Any help with these two problems would be greatly appreciated.

Any archive of plots and code to browse which could help me visually find
what I want and then copy the code?


An online user contributable database of 'graphics in R' would be
smashing.


How come some smart people dont just let me do something like

legend(xpos,ypos,legend=add)

to add a legend to the current plot for all the relevant points and lines
which have been added so far?