[R] One legend for a multiple graph page

Jim Lemon jim at bitwrit.com.au
Mon Aug 23 14:23:19 CEST 2010


On 08/23/2010 09:52 PM, Jordan Ouellette-Plante wrote:
>
>
> Hi,
>
> I am using the Sciplot package to graph barplots. Since I put 4 barplots per page and that the legends are always the same, I would like to find a way to have only one legend per page. Also, I would like it to be centered in the middle of the page. I tried locator() without success.
>
Hi Jordan,
Don't know about Sciplot, but you can do something like this with:

par(mfrow=c(2,2))
par(mar=c(6,4,4,2))
barplot(...)
barplot(...)
par(mar=c(5,4,6,2))
barplot(...)
barplot(...)
par(xpd=TRUE)
# place the legend in the space in the middle
legend(...)
par(xpd=FALSE)

Jim



More information about the R-help mailing list