Movatterモバイル変換


[0]ホーム

URL:


patchwork

R-CMD-checkCRAN_Release_BadgeCRAN_Download_BadgeCodecov test coverage

The goal ofpatchwork is to make it ridiculously simpleto combine separate ggplots into the same graphic. As such it tries tosolve the same problem asgridExtra::grid.arrange() andcowplot::plot_grid but using an API that incitesexploration and iteration, and scales to arbitrarily complexlayouts.

Installation

You can install patchwork from CRAN usinginstall.packages('patchwork'). Alternatively you can grabthe development version from github using devtools:

# install.packages("devtools")devtools::install_github("thomasp85/patchwork")

Basic example

The usage ofpatchwork is simple: just add plotstogether!

library(ggplot2)library(patchwork)p1<-ggplot(mtcars)+geom_point(aes(mpg, disp))p2<-ggplot(mtcars)+geom_boxplot(aes(gear, disp,group = gear))p1+ p2

patchwork provides rich support for arbitrarily complex layouts withfull alignment. As an example, check out this very readable code fornesting three plots on top of a third:

p3<-ggplot(mtcars)+geom_smooth(aes(disp, qsec))p4<-ggplot(mtcars)+geom_bar(aes(carb))(p1| p2| p3)/      p4

Learn more

patchwork can do so much more. Check out the guides for learningeverything there is to know about all the different features:

Code of Conduct

Please note that the patchwork project is released with aContributorCode of Conduct. By contributing to this project, you agree to abideby its terms.


[8]ページ先頭

©2009-2025 Movatter.jp