小编Ant*_*Ant的帖子

R - cowplot:使用 plot_grid 排列 png 图像和 ggplot

我正在尝试使用plot_grid来自 cowplot 包并排排列 png 图像和 ggplot 对象:

library(cowplot)
library(tableHTML)

sg <- data.frame(start = c(0,5,10), 
                 end = c(10,20,30),
                 duration = c(10,15,20), 
                 row.names = c("A","B","C"))

p1 <- ggplot(sg)+
  geom_segment(aes(x=start, y=row_number(start), xend=end, yend=row_number(start)), 
               size = 3) +
  scale_y_reverse(labels = NULL) +
  labs(y = "", x = "") +
  theme(aspect.ratio = 1/5)

sg %>%
  tableHTML() %>%
  add_theme("scientific") %>%
  tableHTML_to_image(file = "image2.png", zoom = 2)

p2 <- ggdraw() + draw_image("image2.png", scale = 0.7)

plot_grid(p2, p1, ncol = 2, scale = c(0.9,1), rel_widths = …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 cowplot

5
推荐指数
0
解决办法
911
查看次数

标签 统计

cowplot ×1

ggplot2 ×1

r ×1