[R] Legend outside plotting area

Vladimir Eremeev wl2776 at gmail.com
Tue May 22 13:32:22 CEST 2007


RSiteSearch("legend outside plot") 
will bring you many links to the discussions of this question.

layout perfectly allows everything.
typical sequence looks like this

This divides the device region by two parts one below another:
layout(matrix(c(1,2),byrow=TRUE), heights=[blah-blah-blah], [some other
arguments])

Then we plot on the first part:
plot( ...  )
lines ( ... )
points ( ... )
grid( ... )
  [ whatever you want on the plotting area] 

Then we finish plotting on the first part of the layout matrix and come to
the next, legend part.
The only thing to do is placing the legend in the top left corner.
plot.new(); 
plot.window(c(0,1), c(0,1));

legend(0,1, [ legend text ] )


Judith Flores wrote:
> 
> 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
> 

-- 
View this message in context: http://www.nabble.com/Legend-outside-plotting-area-tf3794564.html#a10735956
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list