多图图ggplot & Gridextra

Multiple plot picture ggplot & Gridextra

我正在尝试使用 gridExtra 包在彼此之上创建三个 ggplot 图的图片。

我使用的代码是这样的:

require(ggplot2)
library(gridExtra)
library(scales)
library(ggpubr)
library(tidyr)
library(reshape)
library(dplyr)

## GRAPHS

# yearly funding required
yearly1 <- ggplot(yearly, aes(x=year, y=Total_US_required/1000000)) + 
  ggtitle("Total Funding Required") + 
  geom_line(color="darkblue") + 
  labs(y="In Million USD", x="") + xlim(2006,2017)

# yearly funding received
yearly2 <- ggplot(yearly, aes(x=year, y=Total_US_received/1000000)) + 
  ggtitle("Total Funding Received") + 
  geom_line(color="darkblue") + 
  labs(y="", x="") + xlim(2006,2017)

# Yealy funding CERF
yearly3 <- ggplot(yearly, aes(x=year, y=Total_US_received_from.CERF/1000000)) + 
  ggtitle("Total Funding Received CERF") + 
  geom_line(color="darkblue") + 
  labs(y="", x="") + xlim(2006,2017)

## COMBINED PICTURES

tiff('fig1a.tiff', units="in", width=5, height=8.3, res=300)        
grid.arrange(yearly1, yearly2, yearly3, nrow=3, 
             left = textGrob("In Million USD", rot = 90, vjust = 1, hjust=0, 
                             gp = gpar(fontsize = 10)))
dev.off()

我收到以下错误消息:

Error in grid::textGrob(label = label, just = just, hjust = hjust, vjust = vjust,  : 
formal argument "gp" matched by multiple actual arguments

关于如何制作这张图片有什么建议吗?越简单越好。

这是我的数据(压缩):

structure(list(year = 2006:2010, Total_US_received_from.CERF = c(65091455.5, 
    204409211, 200351170.5, 180924822, 290493687.5), Total_US_required = c(828538873.5, 
    2986369814, 1554939106, 2144420061, 7724926517), Total_US_received = c(215790327.5, 
    1988581112, 1698825389, 1509823414, 4975642034)), row.names = c(NA, 
    5L), class = "data.frame")

使用 ggpubr 中的 ggarrange:

yearly1 <- ggplot(yearly, aes(x=year, y=Total_US_required/1000000)) + ggtitle("Total Funding Required") + geom_line(color="darkblue") + labs(y="In Million USD", x="") + xlim(2006,2017)

yearly2 <- ggplot(yearly, aes(x=year, y=Total_US_received/1000000)) + ggtitle("Total Funding Received") + geom_line(color="darkblue") + labs(y="In Million USD", x="") + xlim(2006,2017)

yearly3 <- ggplot(yearly, aes(x=year, y=Total_US_received_from.CERF/1000000)) + ggtitle("Total Funding Received CERF") + geom_line(color="darkblue") + labs(y="In Million USD", x="") + xlim(2006,2017)

ggarrange(yearly1, yearly2, yearly3, 
          ncol = 1, nrow = 3)