[R] Centering a legend
marc_schwartz at comcast.net
Mon May 7 20:06:39 CEST 2007
On Mon, 2007-05-07 at 19:44 +0200, Erich Neuwirth wrote:
> Using layout I am plotting 5 boxplots on top of each other,
> all of them using colored boxes in different order.
> In a 6th box below I want to give the legend explaining the box colors,
> and I want this box to be centered in an otherwise empty plot.
> I am creating this plot by
> Is there an easy way to find the parameters x and y for calling legend
> which will center the legend in this plot?
legend() has positional arguments to enable you to do what you require.
Something along the lines of the following:
# Do your plot
plot(0:1, 0:1, type = "n", ann = FALSE, axes = FALSE)
# Do the legend, centered
legend("center", "This is a test legend")
See the Details section of ?legend, third paragraph. Also, the last set
of examples there.
More information about the R-help