[R] ggplot2: positioning legend on top of plot

Paul Emberson email at calidasoft.co.uk
Mon Nov 24 17:46:46 CET 2008


Hi,

With ggplot2 v0.8, how do I position a legend on top of the plot. Things 
like

p + opts(legend.position="top")

work ok.  But

p + opts(legend.position=c(0.5,0.5))

gives

Error in as.character(x) :
   cannot coerce type 'closure' to vector of type 'character'

so obviously I should be giving a string instead but I can't figure out 
what it should be.

Thanks,

Paul



More information about the R-help mailing list