Skip to content
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

Expanding a discrete scale by an additive constant doesn't work for single level factors #3012

Closed
gdmcdonald opened this issue Nov 20, 2018 · 3 comments

Comments

@gdmcdonald
Copy link

Similar to #2281 but apparently not fixed even with the latest version.

expand_scale(mult = 0, add = 2) doesn't add space around facets with only one discrete factor level in the facet. Doesn't seem like expected behaviour.

ggplot(data = mpg,
       aes(y = model,
           x = cyl,
           color = year))+
  geom_point()+
  facet_grid(manufacturer~.,drop = T, scales = "free_y", space = "free_y")+
  scale_y_discrete(expand = expand_scale(mult = 0, add = 2))+
  theme(strip.text.y = element_text(angle = 0))

mpg_plot

@dpseidel
Copy link
Collaborator

This behavior was actually fixed in the scales 1.0.0 release. See below with the newest release of both scales and ggplot2.

library(ggplot2)
ggplot(data = mpg,
       aes(y = model,
           x = cyl,
           color = year))+
  geom_point()+
  facet_grid(manufacturer~.,drop = T, scales = "free_y", space = "free_y")+
  scale_y_discrete(expand = expand_scale(mult = 0, add = 2))+
  theme(strip.text.y = element_text(angle = 0))

packageVersion("scales")
#> [1] '1.0.0'
packageVersion("ggplot2")
#> [1] '3.1.0'

Created on 2018-11-20 by the reprex package (v0.2.0).

@gdmcdonald
Copy link
Author

My apologies, didn't realise I needed to update the scales package.

@lock
Copy link

lock bot commented May 20, 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 May 20, 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

No branches or pull requests

2 participants