I want to set the panel size of a ggplot facet_wrap to absolute values and receive a ggplot object in return. This part is working. However, for me it is important that the gtable of this ggplot is correct. And this does not seem to be the case.
Any help is very welcome!
# generate plot: works!
p1 <-
ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
facet_wrap(vars(cyl))
# set panel size to absolute values: works!
p1 %>% ggplotGrob() %>% gtable::gtable_show_layout()
p1 %>% egg::set_panel_size() %>% gtable::gtable_show_layout()
# convert to ggplot: works!
p1 %>% egg::set_panel_size() %>% ggpubr::as_ggplot()
p1 %>% egg::set_panel_size() %>% ggplotify::as.ggplot()
# look at gtable of ggplot: corrupted!
p1 %>% egg::set_panel_size() %>% ggpubr::as_ggplot() %>% ggplotGrob() %>% gtable::gtable_show_layout()
p1 %>% egg::set_panel_size() %>% ggplotify::as.ggplot() %>% ggplotGrob() %>% gtable::gtable_show_layout()
# I would except to find the "4cm" that was put in via egg::set_panel_size() earlier.