【问题标题】:How to create Side-by-side plots of Taylor diagram and ggplot?如何创建泰勒图和ggplot的并排图?
【发布时间】:2021-10-19 23:02:44
【问题描述】:

我有两个图,即泰勒图和 ggplot。 我想将它们绘制在一个图中(并排)。 我尝试了“library(patchwork)”,但不幸的是它不起作用。

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")

【问题讨论】:

    标签: r ggplot2 tidyr


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多