Skip to content

fix bad default for legend spacing variables. closes #2943. #3276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

clauswilke
Copy link
Member

This is a minimal fix for #2943. It guarantees that plot legends look fine when legend.title = element_blank(), but otherwise doesn't change the appearance of the legend. In the future, this should be refactored, because the same variables control the overall spacing between the legend title and the legend keys and the spacing between individual legend items. There should be two separate variables for that.

library(ggplot2)

df <- reshape2::melt(outer(1:4, 1:4), varnames = c("X1", "X2"))
p1 <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))

p1 + scale_fill_continuous(guide = guide_legend())

p1 + scale_fill_continuous(guide = guide_legend()) +
  theme(legend.title=element_blank())

p1

p1 + theme(legend.title=element_blank())

Created on 2019-04-26 by the reprex package (v0.2.1)

@clauswilke clauswilke requested a review from thomasp85 April 26, 2019 22:15
@clauswilke clauswilke added this to the ggplot2 3.2.0 milestone Apr 26, 2019
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clauswilke clauswilke merged commit 7582d60 into tidyverse:master Apr 29, 2019
@clauswilke clauswilke deleted the issue-2943-legend.text branch April 29, 2019 14:38
@lock
Copy link

lock bot commented Oct 26, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants