Another solution I've used is to set up an additional layout space and put the legend in there with no graph. You print a blank dummy graph and then add the legend to the "blank" layout panel like so:

if (floatLegend) {
     # We want to float the legend independently
     # so we have to add it here as the only visible component of a
     # dummy graph.

   legText <- yourLegendNames
# create a blank graph -- automatically scales -1 to +1 on both axes
   op <- par(mar=plotMargins)
   tsFake <- barplot(0,0, axes=FALSE)
   legend(x=1, y=0,
          legend=legText,
       # set fill, angle, density to match your real graph scheme
          xjust=1,
          yjust=0.5)
   par(op)
 }

Hope that helps.

--
Patrick Lenon
Database Engineer
Frontier Science and Technology Foundation

(608)441-2947

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to