ggpol icon indicating copy to clipboard operation
ggpol copied to clipboard

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

Open thomas-neitmann opened this issue 5 years ago • 2 comments

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.

thomas-neitmann avatar Feb 22 '20 19:02 thomas-neitmann

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

erocoar avatar Feb 29 '20 10:02 erocoar

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

ReichYang avatar Sep 30 '21 16:09 ReichYang