如何制作一系列ggplots并在它们之间绘制箭头?

rda*_*tor 3 drawing r ggplot2

对于一个项目,我需要绘制一些图并在它们之间放置箭头作为序列的指示.我想知道我是否可以用ggplot来做到这一点.是否可以使用ggplot2绘制一个干净的大箭头并将其添加到最后的多个时间段?

作为一个例子,我使用此代码绘制一个图:

library(ggplot2)
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
Run Code Online (Sandbox Code Playgroud)

对于该项目,我需要绘制三个这样的图.结果应该是这样的:

在此输入图像描述

有没有人有办法解决吗?提前谢谢了!

luk*_*keA 8

这是一种方法:

library(ggplot2)
library(gridExtra)
library(grid)
library(png)
download.file("https://www.wpclipart.com/signs_symbol/arrows/arrow_comic/Arrow_comic_right_gray.png",
              tf <- tempfile(fileext = ".png"),
              mode="wb")
arrow <- rasterGrob(readPNG(tf))
p <- ggplot(diamonds, aes(clarity, fill=cut)) + 
  geom_bar() 
grid.arrange(p + guides(fill = "none"), 
             arrow, 
             p + guides(fill = "none"), 
             arrow, 
             p, 
             ncol=5, widths=c(2/10, 1.75/10, 2/10, 1.75/10, 2.5/10))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述