Skip to content

Make position_dodge2 preserve total width by default #2386

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 2 commits into from
Apr 27, 2018

Conversation

karawoo
Copy link
Member

@karawoo karawoo commented Jan 6, 2018

Closes #2290 by setting the default preserve argument in position_dodge2() to "total".

Before:

ggplot(mtcars, aes(x = factor(vs), y = mpg)) +
  facet_wrap( ~ factor(cyl)) +
  geom_boxplot()

After:

ggplot(mtcars, aes(x = factor(vs), y = mpg)) +
  facet_wrap( ~ factor(cyl)) +
  geom_boxplot()

@karawoo karawoo requested a review from hadley January 6, 2018 05:34
@hadley
Copy link
Member

hadley commented Jan 6, 2018

Do you remember why we set it to single?

@karawoo
Copy link
Member Author

karawoo commented Jan 6, 2018

It was because position_dodge2() is primarily used used for box plots, which can have variable widths but that only works when preserve = "single". So the reasoning was to make the default behavior of position_dodge2() compatible with geom_boxplot(varwidth = TRUE). But this causes the boxes to be too narrow in facetted plots.

I just pushed an update to make sure that preserve gets set back to "single" whenever varwidth = TRUE. We warn the user about the change when they explicitly asked for preserve = "total".

@hadley
Copy link
Member

hadley commented Apr 27, 2018

Thanks!

@lock
Copy link

lock bot commented Oct 24, 2018

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 24, 2018
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