简体   繁体   English

如何创建泰勒图和 ggplot 的并排图?

[英]How to create Side-by-side plots of Taylor diagram and ggplot?

I have two plots ie Taylor diagram and ggplot.我有两个图,即泰勒图和 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")

How about with gridExtra::grid.arrange如何使用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)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM