jonocarroll / ggeasy

ggplot2 shortcuts (transformations made easy)

Home Page:https://jonocarroll.github.io/ggeasy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: `easy_panel_spacing` function

davidhodge931 opened this issue · comments

commented

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

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

commented

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