I'm trying to create a picture of three ggplot graphs on top of each other using the gridExtra package.
The code I'm using is this:
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()
I get following error message:
Error in grid::textGrob(label = label, just = just, hjust = hjust, vjust = vjust, : formal argument "gp" matched by multiple actual arguments
Any suggestions on how to create this picture? The easier the better.
Here's my data (compressed):
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")
nmrow
ingrid.arrange()
should benrow
)? Otherwise I cannot reproduce your error with the provided code. - Z.Lin