[R] Separating point symbols and line types in a legend.

Rolf Turner r.turner at auckland.ac.nz
Fri Feb 12 05:52:48 CET 2016


I would like to have a legend given in the manner

legend("topleft",pch=c(20,8,1),lty=1:3,bty="n",
        legend=c("clyde","irving","melvin"))

but with the point symbol *NOT* being superimposed on the line segments 
that are plotted.

I saw that I can specify "merge=FALSE" in the call to legend() but this 
gives results like unto

    ----* irving

with the plot symbol being immediately juxtaposed to the plotted line 
segment.  I would like a space between them, like so:

    ---- * irving

(See the difference?)

I can see no arguments to legend that allow me to effect this.  I can 
adjust positioning of the legend text, but not of the plotted point 
character or line segment.  Is there any way to effect the desired 
result?  Or is there a "simple" adjustment that one could make to the 
code for legend() that would allow me to accomplish what I want?

Ta.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list