[R] Plotting legend outside of multiple panels
Jim Lemon
jim at bitwrit.com.au
Mon May 3 14:27:03 CEST 2010
On 05/03/2010 05:15 PM, John Poulsen wrote:
> Hello,
>
> I have used layout() to produce to 2 plots on a page, leaving a plotting space above them. I would like "Legend", which will actually be a real legend, to be centered above the two graphs. Right now I am only able to position "Legend" above the second graph that I create... obviously I am stuck in its margin space.
>
> Is there a way to draw the legend in the empty plotting space above? Or is there a way to center the legend in the margin space above the two graphs.
>
> I am open to using par(mfrow=c(2,2)) rather than layout(), but it currently produces the same result.
>
Hi John,
Try using par(xpd=NA) that allows you to draw anywhere on the device,
and then place your legend relative to the current plotting area. See
the help page for zoomInPlot (plotrix) for an example.
Jim
More information about the R-help
mailing list