[R] How can we add a legend to a set of graphs?

Duncan Murdoch murdoch at stats.uwo.ca
Sat May 19 02:26:45 CEST 2007


On 18/05/2007 7:33 PM, Judith Flores wrote:
> Hi,
> 
>    I have a set of 4 graphs and I need to add a legend
> that is shared by those 4 graphs. This is what I
> tried:
> 
>> locator(1) # I placed the cursor in the center of the
> 4 graphs
> $x
> [1] 9.299001
> 
> $y
> [1] 226.3201
> 
> 
>> legend(9.3,226.3,"and the rest of the legend
> arguments")# but the legend didn't show.
> 
>     The legend only appears when I place in inside any
> of the for plots. How can I place it outside these
> plots, in the center.

RSiteSearch("legend outside")

suggests using par(xpd=TRUE).

Duncan Murdoch



More information about the R-help mailing list