Re: [R] barplot legend

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Fri 01 Jul 2005 - 22:41:39 EST

On Fri, 2005-07-01 at 14:04 +0200, Navarre Sabine wrote:
> Hi,
>
> Is it possible ti put the legend out of a barplot?
>
> tanks
>
> Sabine

I presume that you mean outside the plot region?

If so, you can use something like the following:

# Adjust the plot margins to make room for the # legend on the right side. See ?par
par(mar = c(5, 4, 4, 10) + 0.1)

barplot(1:10)
box()

# Set xpd to allow legend placement outside # plot region. See ?par
par(xpd = TRUE)

# Left click on the right side of the window where you want # the legend. See ?locator
l <- locator(1)

# Now put the legend where you clicked
# See ?legend
legend(l$x, l$y, legend = "Legend Here")

HTH, Marc Schwartz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 01 22:46:06 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:08 EST