teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
542 stars 33 forks source link

bleed=FALSE not working in facet_nested for multi-layer facets? #7

Closed AndyKingham-NOAA closed 4 years ago

AndyKingham-NOAA commented 4 years ago

Hi, THANK YOU for this great package, I came across it and it has helped me a lot. I am using facet_nested in a series of graphs with up to 5 nestings in the horizontal facets. I would like the child layers to not be "bled" together. It looks like the bottom-most layer is correctly not bleeding, as it should with the argument bleed=FALSE. But everything above that is still bleeding. It's probably something simple but I can't figure out how to change it. Not sure if this is the correct platform to post this question, but giving it a shot. I'm including an image, if you need more info I can try to come up with a reproducible example.
Thanks, ADK

facet_nested_bleed_issue

teunbrand commented 4 years ago

Hi, you are right to post a possible bug here, thanks for letting me know. I can confirm that I can reproduce the error and that this indeed not the intended behaviour. Here is how to reproduce:

library(ggh4x)
#> Loading required package: ggplot2

df <- data.frame(
  nest1 = rep(LETTERS[1:2], c(4,2)),
  nest2 = rep(LETTERS[3:5], c(2,2,2)),
  nest3 = rep(LETTERS[6:8], c(1,2,3)),
  nest4 = rep(LETTERS[9:14]),
  x = 1
)

ggplot(df, aes(x, x)) +
  geom_point() +
  facet_nested(~ nest1 + nest2 + nest3 + nest4,
               bleed = FALSE)

Created on 2020-04-18 by the reprex package (v0.3.0)

I'll go see how to fix this

teunbrand commented 4 years ago

The following should work now:

library(ggh4x)
#> Loading required package: ggplot2

df <- data.frame(
  nest1 = rep(LETTERS[1:2], c(4,2)),
  nest2 = rep(LETTERS[3:5], c(2,2,2)),
  nest3 = rep(LETTERS[6:8], c(1,2,3)),
  nest4 = rep(LETTERS[9:14]),
  x = 1
)

p <- ggplot(df, aes(x, x)) +
  geom_point()

p + facet_nested(~ nest1 + nest2 + nest3 + nest4,
                 bleed = TRUE)


p + facet_nested(~ nest1 + nest2 + nest3 + nest4,
                 bleed = FALSE)

Created on 2020-04-18 by the reprex package (v0.3.0)

AndyKingham-NOAA commented 4 years ago

Man you are quick. And it worked after I re-installed the package! Thank you

teunbrand commented 4 years ago

Alright, thanks for reporting the bug!