0.5.3
从flextable版本开始就有可能。有很多方法可以实现这一点,这里有一个例子:
library(ggplot2)
library(grid)
library(cowplot)
library(dplyr)
# remotes::install_github("davidgohel/flextable")
library(flextable)
gg1 <- ggplot(iris, aes(Sepal.Length, Petal.Length, color = Species) ) + geom_point()
ft_raster <- iris %>% group_by(Species) %>%
summarise_all(median) %>%
flextable() %>% autofit() %>%
as_raster()
gg2 <- ggplot() +
theme_void() +
annotation_custom(rasterGrob(ft_raster), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)
cowplot::plot_grid(gg1, gg2, nrow = 2, ncol = 1, rel_heights = c(3, 1) )
结果如下