Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-cowplot:使用plot_网格排列png图像和ggplot_R_Ggplot2_Cowplot - Fatal编程技术网

R-cowplot:使用plot_网格排列png图像和ggplot

R-cowplot:使用plot_网格排列png图像和ggplot,r,ggplot2,cowplot,R,Ggplot2,Cowplot,我正在尝试使用cowplot软件包中的plot\u grid并排排列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"))

我正在尝试使用cowplot软件包中的
plot\u grid
并排排列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 = c(1, 2))
库(cowplot)
图书馆(表格HTML)
sg%
添加主题(“科学”)%>%
tableHTML_到_图像(file=“image2.png”,zoom=2)
p2