Zeljko Vrba
2009-May-10 15:32 UTC
[R] ggplot2: recommended workaround for broken legend.position="top"
Searching the mail archives I found that using legend.position as in p.ring.3 + opts(legend.position="top") is a known bug. I tried doing p.ring.3 + opts(legend.position=c(0.8, 0.2)) which works, but the legend background is transparent, i.e. I see the plot background through the legend. Adding additional option opts(legend.background=theme_rect(fill=TRUE,colour="white")) fills the whole rectangle black(!), making text invisible, but leaves the shape symbols visible. So, how can I obtain a graph with legend positioned within the plot boundaries (that's OK, I don't even mind manually positioning the legend), but on a white background, i.e., so that the plot underneath is not visible? Thanks.
hadley wickham
2009-May-10 15:40 UTC
[R] ggplot2: recommended workaround for broken legend.position="top"
On Sun, May 10, 2009 at 10:32 AM, Zeljko Vrba <zvrba at ifi.uio.no> wrote:> Searching the mail archives I found that using legend.position as in > p.ring.3 + opts(legend.position="top") > > is a known bug. ?I tried doing > p.ring.3 + opts(legend.position=c(0.8, 0.2)) > > which works, but the legend background is transparent, i.e. I see the > plot background through the legend. ?Adding additional option > > opts(legend.background=theme_rect(fill=TRUE,colour="white")) > > fills the whole rectangle black(!), making text invisible, but leaves the shape > symbols visible. > > So, how can I obtain a graph with legend positioned within the plot boundaries > (that's OK, I don't even mind manually positioning the legend), but on a white > background, i.e., so that the plot underneath is not visible?opts(legend.background=theme_rect(fill="white")) Hadley -- http://had.co.nz/