erocoar / ggpol

🌍 Parliament diagrams and more for ggplot2
https://erocoar.github.io/ggpol/
Other
104 stars 10 forks source link

Common limits for both facets when using `facet_share()` #7

Open thomas-neitmann opened 4 years ago

thomas-neitmann commented 4 years ago

I would like to have a common limit for both facets when using facet_share(). In the example below the largest value on the left is 10 whereas it is 5 on the right. Because the limits are not the same, it looks as though the values are equal.

library(ggplot2)
sex <- rep(c("male", "female"), each = 5)
cat <- rep(LETTERS[1:5], 2)
val <- c(1:5, -(6:10))
df <- tibble::tibble(sex, cat, val)

p <- ggplot(df, aes(cat, val, fill = sex)) +
  geom_col() +
  ggpol::facet_share(vars(sex), scales = "free", reverse_num = TRUE) + 
  coord_flip()
p

image

A naive way to set the limits failed as expected.

p + ylim(0, 10)

image

It would be great to have an option for both facets to have the same limits.

erocoar commented 4 years ago

Hi, thanks for your feedback. I think that's a great idea. Unfortunately for ggpol 0.0.6 I temporarily removed facet_share, because it is incompatible with upcoming changes both in grid and ggplot2. The rewrite will take some time - but I hope to have more news soon

ReichYang commented 3 years ago

Hi. I'm using ggpol for the population pyramid and faced the same problem. Are there any updates or workarounds on this? @erocoar