[R] Rotate legends or other approaches to nice legend placement?

Alex Brown alex at transitive.com
Mon Jul 4 12:19:16 CEST 2005


I'm sure this general sort of question has been asked many times before 
- I would _like_ automatic and sensible legend placement in barplots so 
data is not overwritten... but since there doesn't seem to be one, one 
of the following would be useful:

One approach for this would be to place the legend to the right of the 
graph, and rotate it by 90 degrees.

Is there a sensible way to do this?

alternatively, is there a function to

1) estimate legend size
2) adjust nrows so that the full width of the drawing device is used, 
minimising height
3) use layout() so that enough space is allocated beneath the graph for 
the legend
4) draw legend
5) allow user to call plot, correctly drawing the plot in the remaining 
frame?

I have taken a look at this, but I am confused by the different units 
used by par(mar), legend(plot=F), and layout.

-Alex Brown




More information about the R-help mailing list