I have the following plot:
library(grid)
library(ggplot2)
p <-
qplot(1:10, 1:10, color = letters[1:10]) +
theme_grey(base_size = 24)
But I'd like the legend title to be closer to the legend keys. I know I can just white-out the legend and overwrite it using grid.text
:
p <-
qplot(1:10, 1:10, color = letters[1:10]) +
theme_grey(base_size = 24) +
theme(legend.title = element_text(color = "white"))
grid.newpage()
grid.draw(p)
grid.text(x = 0.87, y = 0.7, label = "LETTERS")
But this approach has the disadvantage of being inflexible.
I also tried adjusting arguments to theme(legend.title = element_text(...))
such as vjust = 1
but that had no effect (apparently a known issue).
Is there a better/canonical way to modify the legend title position?