r语言ggplot2一夜多图_ggplot2绘图:多张图合并为一张
以下內容來自教程
R語言中多張圖畫到同一個頁面上常用的函數(shù)為par()和layout()
par()函數(shù)詳解
layout()函數(shù)的簡單使用
但是這兩個函數(shù)不適用于ggplot2;ggplot2作圖如果希望把多張圖放到同一個頁面上基本的解決辦法是使用(The basic solution is to use the gridExtra R package),主要的兩個函數(shù)為grid.arrange(),arrangeGrob();然而這兩個函數(shù)都有各自的缺點(說明缺點的英文暫時還沒有看懂)
these functions makes no attempt at aligning the plot panels; instead, the plots are simply placed into the grid as they are, and so the axes are not aligned.
為了解決這個問題,可以使用cowplot這個Rpackage,其中包括一個函數(shù)plot_grid();然而這個包也有一個缺點
the cowplot package doesn’t contain any solution for multi-pages layout
所以就有了ggpubr包中的ggarrange()函數(shù)
a wrapper around the plot_grid() function(wrapper是什么意思呢?)
to arrange multiple ggplots over multiple pages
it can also create a common unique legend for multiple plots.
第一步安裝
兩種方式可以選擇
1
library(devtools)
install_github("kas
總結
以上是生活随笔為你收集整理的r语言ggplot2一夜多图_ggplot2绘图:多张图合并为一张的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux c++ queue 多线程,
- 下一篇: 定期产品会不会亏?分三种情况介绍