[R] Legend outside plotting area

Carsten Jaeger carsten_jaeger at web.de
Tue May 22 13:33:33 CEST 2007


Judith,

you might try split.screen() and related functions, see ?screen.

Example:
split.screen(c(1,2)) # 1 row, 2 columns
split.screen(c(2,2), screen = 1) # split left column into 2x2
for(i in 3:6) { screen(i); plot(1:10) }
screen(2)
plot(1, type="n", axes=F, ann=F) # empty plot
legend("center", pch=1, legend="Data")


Regards,

Carsten

> Hi, 
> 
>     I have been trying many of the suggested options
> to place a legend outside plotting area, including
> something like this:
> 
> par(xpd=T,
> oma=par()$oma+c(4.5,0,1.5,0),mar=par()$mar+c(1,0,1,0)
> 
> 
>     But the aspect of the four plots gets compromised
> when I change the margin settings. I cannot use mtext
> because I need to use colors for the text. I tried
> layout, but wouldn't let me include the legend, only
> plots.
> 
>    I would appreciate very much some more help.
> 
> Regards,
> 
> J



More information about the R-help mailing list