Skip to content

Length of legend title affects justification of legend keys/labels? #1903

Closed
@orb16

Description

@orb16

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions