美文网首页
【R语言】 cowplot包快速拼图

【R语言】 cowplot包快速拼图

作者: 花生学生信 | 来源:发表于2024-04-14 14:33 被阅读0次
    library(cowplot)
    library(ggplot2)
    library(cowplot)
    #install.packages("magick")
    library(magick)
    devtools::install_github("GuangchuangYu/ggimage")
    devtools::install_github("GuangchuangYu/ggplotify")
    devtools::install_github("GuangchuangYu/yyplot")
    
    ###画图
    p1<-ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.7)
    p2 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.7)
    p3<-ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.7)
    

    拼图

    plot_grid(p, p1,p3,labels = "AUTO")
    

    也可以根据需要进行调整

    plot_grid(
      plot_grid(p1, p3$gtable, ncol=2, rel_widths=c(.6, 1), labels=LETTERS[1:2]),
      p3, ncol=1, labels=c("", "C"))
    
    plot_grid(p1,p1,p1,p1,
              labels = c('A','B','C','D'),
              ncol = 1, nrow = 4)
    

    相关文章

      网友评论

          本文标题:【R语言】 cowplot包快速拼图

          本文链接:https://www.haomeiwen.com/subject/szlrxjtx.html