[R] Legend for 2 plots on same screen

Jim Lemon jim at bitwrit.com.au
Mon Aug 1 12:14:58 CEST 2011


On 08/01/2011 04:52 AM, Cheryl Johnson wrote:
> Hello,
>
> I have two plots on the same screen. I use the command par(mfrow=c(1,2)) in
> order to do this. When I try to make a legend for both plots, it only puts
> the legend in the plot on the right side. If I would like a legend that is
> outside of both of the plots, how would I do this?
>
Hi Cheryl,
You probably want to use par(xpd=TRUE) to allow displaying the legend 
outside the plot areas. Look at the color.legend (plotrix) function to 
see how it's done.

Jim



More information about the R-help mailing list