teunbrand / ggh4x

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

facet_grid with remove_labels removes labels but leaves the space between the panels #158

Open Ari04T opened 2 months ago

Ari04T commented 2 months ago

Hello

Basically what the title says. facet_grid2 by the way, sorry about the mistake in the title.

mpg %>% 
  ggplot(aes(cyl, class)) +
  geom_point() +
  facet_grid2(. ~ manufacturer, axes = "all", remove_labels = "y")

This is the final result. The labels are removed but the space remains.

Screenshot 2024-05-07 063604

I'm currently using ggplot 3.5.1 with ggh4x 0.2.8.9000

Thanks!

teunbrand commented 2 months ago

Thanks for the report. I can reproduce the bug and it would need to get fixed. If that is the only reason for using facet_grid2(), I can also recommend ggplot2::facet_grid() to achieve the same goal since 3.5.0.

library(ggplot2)

mpg |>
  ggplot(aes(cyl, class)) +
  geom_point() +
  facet_grid(. ~ manufacturer, axes = "all", axis.labels = "all_x")

Created on 2024-05-07 with reprex v2.1.0

Ari04T commented 2 months ago

Thanks for the suggestion. I'm actually using strip_nested for my actual charts to I do need to use facet_grid2 to get the full capabilities of ggh4x.

I think I can get around it for now by just using theme(panel.spacing = unit(-30, "pt")) or similar to get around the current bug, but I just wanted to let you know that the package is creating this unexpected result at the moment.