[R] ggplot: Problem with legend background

MUHC_Research villandl at dms.umontreal.ca
Fri Dec 11 16:26:34 CET 2009


Dear R-users,

I am preparing graphs for an upcoming article using the different functions
of the ggplot2 package and I've been having problems with the legend
background. It doesn't seem to scale when the text size is increased. Here's
the mandatory reproducible example:

library(ggplot2)
repFrame <- data.frame(A= 1:10, B= rnorm(1:10), groupNum = rep(c("First
group", "Second group"),each=5))
testPlot <- ggplot(repFrame, aes(x=A, y = B, group = groupNum)) +
opts(legend.position=c(0.85,0.3), legend.background =
theme_rect(fill="white"), legend.text=theme_text(size=16),
legend.title=theme_text(size=20))
testPlot + geom_point(aes(colour= groupNum))

As you can see, the text doesn't fit in the white rectangle. I suspect there
is a theme setting I could modify to fix this, but I can't seem to find
which one.

I sincerely thank you for your time and assistance.

Luc
-- 
View this message in context: http://n4.nabble.com/ggplot-Problem-with-legend-background-tp961142p961142.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list