Not sure if it's a recent change (I'm using the dev version fresh from github), but with a large enough font the legend title collides with the legend and I can't find any setting to move it.
set.seed(123) dummy <- data.frame(x=runif(10), y=runif(10), f = gl(2,5)) ggplot(dummy, aes(x,y, shape=f)) + geom_point() + labs(shape="guide") + theme_grey(24)
With the default font size things are OK, albeit snug
With a larger font size (graphic aimed for slides), however,
legend.margin = margin(100,100,100,100) legend.spacing.y = unit(1,"cm") legend.title = element_text(vjust = 2)
also played with guide_legend etc. to no avail.
The text was updated successfully, but these errors were encountered:
the relevant part seems to be in guide-legend.r
First, the text height is not accurately measured,
g <- ggplot2:::element_grob( element_text(angle = 0), label = "guide", hjust = 0.5, vjust = 0.5, expand_x = FALSE, expand_y = FALSE ) grid.newpage() grid.draw(g) grid.rect(height=unit(ggplot2:::height_cm(g), "cm"),gp=gpar(fill=NA))
(it seems to be a limitation in grid, descenders aren't included for some reason). Not much to do about it. In passing
And second there isn't any setting to change the margin,