Closed
Description
This produces a nicely centred title (and centred legend text):
require(ggplot2)
data(iris)
ggplot(iris, aes(y = Sepal.Width, x = Petal.Width)) +
geom_point(shape = 21, aes(fill = Species)) +
guides(fill = guide_legend(title.position = "top", title.hjust = 0.5)) +
scale_fill_manual("Species", values = c("orange", "black", "white"))
Here changing the length of the legend title appears to affect the justification of the legend text:
ggplot(iris, aes(y = Sepal.Width, x = Petal.Width)) +
geom_point(shape = 21, aes(fill = Species)) +
guides(fill = guide_legend(title.position = "top", title.hjust = 0.5)) +
scale_fill_manual("A really, really long title that is sometimes necessary involving species",
values = c("orange", "black", "white"))
Using ggplot2_2.1.0 and R version 3.2.4 Revised