[R] Separating point symbols and line types in a legend.
Rolf Turner
r.turner at auckland.ac.nz
Fri Feb 12 22:29:45 CET 2016
Thanks Greg. Worked perfectly!!!
cheers,
Rolf
On 13/02/16 09:22, Greg Snow wrote:
> One option is to call `legend` twice and do some manual positioning.
> This worked for me:
>
> plot(1:10)
> legend('topleft', lty=1:3, bty="n", legend=c('','','') )
> legend('topleft', pch=c(20,8,1), bty="n",
> legend=c('clyde','irving','melvin'), inset=c(0.1,0))
>
> You may need to fiddle with the amount of inset for your particular
> plot and device combination.
>
>
>
> On Thu, Feb 11, 2016 at 9:52 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>>
>> 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.
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
More information about the R-help
mailing list