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

Dan Bolser dmb at mrc-dunn.cam.ac.uk
Thu Nov 25 20:25:30 CET 2004


Is this an impossible task?

How about just problem 2 below, having one pch in one legend entry, but no
pch in the second?




On Thu, 25 Nov 2004, Dan Bolser wrote:

>
>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?
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list