[R] How to adjust the distance between legend and the plot (xyplot)

Peter Ehlers ehlers at ucalgary.ca
Mon Apr 16 23:29:27 CEST 2012


On 2012-04-16 08:51, David Winsemius wrote:
>
> On Apr 16, 2012, at 11:43 AM, Jun Shen wrote:
>
>> Dear list,
>>
>> As the title indicates if I draw the legend outside of the plot, how
>> do I
>> adjust the distance between the legend and the plot? The default
>> setting is
>> too close. Thanks.
>
>    From the help page:
>
> "just
> A character or numeric vector of length one or two giving horizontal
> and vertical justification for the placement of the legend. See
> grid.layout for more precise details."
>
>

I would have a look at the layout.heights trellis parameters and set
these to suit - in this case probably just the xlab.key.padding value.

Look at the list of parameters with

   trellis.par.get("layout.heights")

# (or wrap this in str() for a briefer output).

Then include a par.settings argument in the xyplot call:

   xyplot( 1 ~ 1,
          par.settings = list( layout.heights = list(
               xlab.key.padding = 5 )),
          key = list( .... etc


Peter Ehlers

>
>
>
>>
>> Here is the sample code I have
>>
>> ==========================================================
>> xyplot
>> (1~1,key=list(space='bottom',columns=2,text=list(c('a','b','c','d')),
>> lines
>> =list(lwd=2,pch=c(1,1,2,2),cex=1.2,col=c(1,2,3,4),type=c('p','l')))
>> )
>>
>> Jun
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list