thomasp85 / patchwork

The Composer of ggplots
https://patchwork.data-imaginist.com
Other
2.48k stars 163 forks source link

Set table theme based on ggplot2 theme? #391

Open thomasp85 opened 2 months ago

thomasp85 commented 2 months ago

It could be pretty nifty if we could derive a nice compatible theming of gt tables from a complete ggplot2 theme...

thomasp85 commented 2 months ago

It may be hard because the intent of the theme is not always obvious from its parts. E.g. theme_minimal() has the intention of minimalism but there is no obvious way to deduce that other than looking at it's effect on a plot

thomasp85 commented 2 months ago

@teunbrand any ideas for this?

teunbrand commented 2 months ago

I had a bit of an experiment going with more formally putting gt tables as legends/axes. The code I used to homogenise styling lives here: https://github.com/teunbrand/gtguides/blob/138c17c177c03e64624052f88a4875592dbff2d6/R/gtlegend.R#L197-L240 However, this is a first draft and doesn't really cover everything.

It'd be easier if tables had dedicated ggplot2 theme elements to deal with table specific stuff like stripes and such. The question however is where these theme settings should live. {gt} has no dependency on {ggplot2} and {ggplot2} has no intrinsically motivated reason to incorporate such elements.

teunbrand commented 2 months ago

Perhaps too specifically, I've also had some more detailed ideas.

thomasp85 commented 2 months ago

Yeah, I was thinking something along those lines but I'm still unsure whether the end result would feel "native" to the plot.