Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set table theme based on ggplot2 theme? #391

Open
thomasp85 opened this issue Sep 10, 2024 · 5 comments
Open

Set table theme based on ggplot2 theme? #391

thomasp85 opened this issue Sep 10, 2024 · 5 comments

Comments

@thomasp85
Copy link
Owner

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

@thomasp85
Copy link
Owner Author

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
Copy link
Owner Author

@teunbrand any ideas for this?

@teunbrand
Copy link
Contributor

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
Copy link
Contributor

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

  • We could use the plot.background and panel.background to have alternating colours for striping. This would mean theme_gray() has striping but theme_minimal() does not.
  • The panel.grid could determine what the body cell borders looks like, so theme_minimal() would have light gray borders, theme_gray() white borders (that only show up on striped cells) and theme_classic() would have no borders.
  • The panel.border could be used for the first and last borderlines that set apart the table body.

@thomasp85
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants