I have two plots i.e. Taylor diagram and ggplot. I would like to plot them in a single plot (side-by-side). I tried "library(patchwork)", but unfortunately it doesn't work.
library(tidyr)
library(openair)
dat=data.frame(
a=runif(10),
b=runif(10)
)
dat = gather(dat, columnNames, values)
colnames(dat)=c("model", "x")
dat$b=runif(20)
plot1= ggplot(dat, aes(x = x, y = b, group = model,
color = model, shape = model))
geom_point( aes(colour = model))
#plot-2
dates <- seq(as.Date("2015-01-01"),as.Date("2015-12-31"),1)
obs=runif(365)
mod=runif(365)
model=rep(c("model1","model2"),times=c(150,215))
mod.dat <- data.frame(dates,obs,mod,model)
TaylorDiagram(mod.dat, obs = "obs", mod = "mod", group = "model")
CodePudding user response:
How about with gridExtra::grid.arrange
library(ggplot2)
library(tidyr)
library(openair)
dat=data.frame(
a=runif(10),
b=runif(10)
)
dat = gather(dat, columnNames, values)
colnames(dat)=c("model", "x")
dat$b=runif(20)
plot1= ggplot(dat, aes(x = x, y = b, group = model,
color = model, shape = model))
geom_point( aes(colour = model))
#plot-2
dates <- seq(as.Date("2015-01-01"),as.Date("2015-12-31"),1)
obs=runif(365)
mod=runif(365)
model=rep(c("model1","model2"),times=c(150,215))
mod.dat <- data.frame(dates,obs,mod,model)
plot2 <- TaylorDiagram(mod.dat, obs = "obs", mod = "mod", group = "model")
gridExtra::grid.arrange(plot1, plot2$plot, ncol = 2)