Skip to content

trouble positioning legends on barplot written to a file

1 message · Warnes, Gregory R

#
You might consider putting the legend in a separate plot area.  For
instance, using the layout function:

library(grid)
data(VADeaths, package = "base")
layout( cbind(1,2), widths=c(8,3) )  # make two plotting areas, 
                                     #   8 and 3 units wide
barplot(VADeaths, plot = TRUE)       # generate the barplot
plot.new()                           # move to the new region
legend(x=0.5,y=0.5,letters[1:5],     # center a legend in the new
       fill=heat.colors(5)[1:5],     #   plot region
       xjust=0.5,yjust=0.5)

-Greg
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._