jonocarroll / ggeasy

ggplot2 shortcuts (transformations made easy)
https://jonocarroll.github.io/ggeasy/
274 stars 20 forks source link

Feature request: `easy_panel_spacing` function #66

Open davidhodge931 opened 1 year ago

davidhodge931 commented 1 year ago

Great package!

It'd be cool to have a function that easily adjusts the panel spacing.

So code that does this in an easy way.

library(palmerpenguins)
library(tidyverse)

p <- penguins |>
  ggplot() +
  geom_histogram(aes(x = flipper_length_mm)) +
  facet_grid(sex ~ species)

p + 
  theme(panel.spacing = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).


p + 
  theme(panel.spacing.x = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).


p +
 theme(panel.spacing.y = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

Created on 2023-08-24 with reprex v2.0.2

jonocarroll commented 1 year ago

Thanks! This looks like a good fit - no promises on timing, but it should be entirely possible.

davidhodge931 commented 1 year ago

Great, thanks :)

You might be interested in my package {ggblanket} - it has similar aims to ggeasy. Making ggplot2 simpler. It's not focussed on themes though, like ggeasy is - so the 2 packages work together nicely.

https://davidhodge931.github.io/ggblanket/index.html