Patrick,

Thanks for the tip below.  It took me awhile to get to it, but your solution worked great.  In case it is useful for other people, below is a very simple example where I create two plots side by side with the legend centered on top.

John


## Example plot for R server
        par(mar=c(3,5,0,5))
        layout(rbind(c(4,1,1,5), c(2,2,3,3)), widths=c(1,1,1,1), heights=c(.75,2.25))
           barplot(0,0, axes=FALSE)
             legend(x=0.5, y=0, legend=c("Example 1", "Example 2"), pch=c(1,2), cex=1.5, xjust=1, yjust=0.5, bty="n")
         plot(1:10,1:10, pch=1)
         plot(1:20,1:20, pch=2)
   

   

On May 4, 2010, at 9:22 AM, Patrick Lenon wrote:

> 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
> 


	[[alternative HTML version deleted]]

