patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

Support for gt_tbl objects

Open MokeEire opened this issue 4 years ago • 4 comments

Are there any plans to support gt_tbl objects from {gt}?

Ideally this would look like:

library(tidyverse)
library(patchwork)
library(gt)

# simple table
mt_tab = gt(mtcars) 

# simple scatterplot
mt_plot = ggplot(mtcars, aes(x = mpg, y = hp, colour = cyl))+
    geom_point()

# using wrap elements because this seems to be the answer to non-ggplot grobs e.g. #164 
wrap_elements(full = mt_tab | mt_plot)

Potential output

gt_patch, used custom theming

MokeEire avatar Aug 14 '20 17:08 MokeEire

Yes, that is the plan. Waiting for gt to get a grob conversion

thomasp85 avatar Aug 14 '20 21:08 thomasp85

One thing that would be amazing with patchworks of gt abd ggplot grobs is if the rows of the table could be aligned with factors on the y axis of the plot. I'm mainly thinking of this for meta-analysis forest plots, which usually include a table of stats for each study alongside https://en.wikipedia.org/wiki/Forest_plot

bwiernik avatar Nov 05 '20 18:11 bwiernik

I think that would potentially be too involved - I try to stay clear of adding a bunch of special alignment features for specific elements in some plots, as it would deteriorate the code in a few seconds :-)

thomasp85 avatar Nov 05 '20 18:11 thomasp85

Potentially at least getting the bottom of the header to line up with the top of the plot area and and the last row to line up with the bottom of the plot area might be enough m if that were easier

bwiernik avatar Nov 05 '20 23:11 bwiernik