├── docs ├── .nojekyll ├── logo.png ├── favicon.ico ├── favicon-16x16.png ├── favicon-32x32.png ├── reference │ ├── p1.png │ ├── p2.png │ ├── p3.pdf │ ├── p4.pdf │ ├── Rplot001.png │ ├── Rplot002.png │ ├── Rplot003.png │ ├── Rplot004.png │ ├── Rplot005.png │ ├── Rplot006.png │ ├── Rplot007.png │ ├── Rplot008.png │ ├── Rplot009.png │ ├── add_sub-1.png │ ├── add_sub-2.png │ ├── add_sub-3.png │ ├── add_sub-4.png │ ├── as_grob-1.png │ ├── ggdraw-1.png │ ├── stamp-1.png │ ├── stamp-2.png │ ├── draw_grob-1.png │ ├── draw_line-1.png │ ├── draw_plot-1.png │ ├── draw_text-1.png │ ├── draw_text-2.png │ ├── get_panel-1.png │ ├── get_panel-2.png │ ├── get_title-1.png │ ├── get_title-2.png │ ├── plot_grid-1.png │ ├── plot_grid-2.png │ ├── plot_grid-3.png │ ├── plot_grid-4.png │ ├── plot_grid-5.png │ ├── plot_grid-6.png │ ├── plot_grid-7.png │ ├── plot_grid-8.png │ ├── plot_grid-9.png │ ├── theme_map-1.png │ ├── theme_map-2.png │ ├── align_margin-1.png │ ├── align_plots-1.png │ ├── axis_canvas-1.png │ ├── axis_canvas-2.png │ ├── axis_canvas-3.png │ ├── draw_image-1.png │ ├── draw_image-2.png │ ├── draw_image-3.png │ ├── draw_image-4.png │ ├── draw_label-1.png │ ├── draw_label-2.png │ ├── draw_label-3.png │ ├── draw_label-4.png │ ├── figures │ │ ├── logo.png │ │ └── cowplot-logo.png │ ├── get_legend-1.png │ ├── get_legend-2.png │ ├── get_legend-3.png │ ├── get_legend-4.png │ ├── get_legend-5.png │ ├── get_legend-6.png │ ├── get_y_axis-1.png │ ├── get_y_axis-2.png │ ├── theme_cowplot-1.png │ ├── theme_nothing-1.png │ ├── background_grid-1.png │ ├── draw_figure_label-1.png │ ├── draw_figure_label-2.png │ ├── draw_figure_label-3.png │ ├── draw_figure_label-4.png │ ├── draw_figure_label-5.png │ ├── get_plot_component-1.png │ ├── rectangle_key_glyph-1.png │ ├── rectangle_key_glyph-2.png │ ├── theme_minimal_grid-1.png │ ├── theme_minimal_grid-2.png │ └── theme_minimal_grid-3.png ├── apple-touch-icon.png ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── articles │ ├── themes_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-9-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-13-1.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-15-1.png │ │ │ └── unnamed-chunk-16-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ ├── plot_grid_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-4-2.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-5-2.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-9-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-13-1.png │ │ │ └── unnamed-chunk-14-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ ├── aligning_plots_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-1-2.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-2-2.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-3-2.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-9-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ └── unnamed-chunk-12-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ ├── introduction_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-1-2.png │ │ │ ├── unnamed-chunk-1-3.png │ │ │ ├── unnamed-chunk-1-4.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-2-2.png │ │ │ ├── unnamed-chunk-2-3.png │ │ │ ├── unnamed-chunk-2-4.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ └── unnamed-chunk-6-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ ├── shared_legends_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ └── unnamed-chunk-6-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ ├── drawing_with_on_plots_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-9-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-13-1.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ └── unnamed-chunk-15-1.png │ │ └── header-attrs-2.3 │ │ │ └── header-attrs.js │ └── mixing_plot_frameworks_files │ │ ├── figure-html │ │ ├── unnamed-chunk-1-1.png │ │ ├── unnamed-chunk-2-1.png │ │ ├── unnamed-chunk-3-1.png │ │ ├── unnamed-chunk-4-1.png │ │ ├── unnamed-chunk-4-2.png │ │ ├── unnamed-chunk-5-1.png │ │ ├── unnamed-chunk-5-2.png │ │ ├── unnamed-chunk-6-1.png │ │ ├── unnamed-chunk-7-1.png │ │ └── unnamed-chunk-8-1.png │ │ └── header-attrs-2.3 │ │ └── header-attrs.js ├── pkgdown.yml ├── link.svg ├── bootstrap-toc.css ├── docsearch.js ├── sitemap.xml └── pkgdown.js ├── .codecov.yml ├── tests ├── testthat │ ├── .gitignore │ ├── helper-vdiffr.R │ ├── test_ggdraw.R │ ├── test_get_titles.R │ ├── test_get_panel.R │ ├── test_get_axes.R │ ├── test_key_glyph.R │ ├── test_plot_components.R │ ├── _snaps │ │ ├── draw_ │ │ │ ├── label-color-taken-from-theme.svg │ │ │ ├── label-color-specified-w-uk-spelling.svg │ │ │ └── label-color-specified-w-us-spelling.svg │ │ ├── key_glyph │ │ │ ├── rectangle-key-glyph-color-used-as-fill.svg │ │ │ └── circle-key-glyph-color-used-as-fill.svg │ │ └── plot_grid │ │ │ ├── colwise-arranging.svg │ │ │ ├── setting-heights-1-1-2.svg │ │ │ ├── setting-widths-1-1-2.svg │ │ │ ├── basic-plot-arranging-with-missing-plot.svg │ │ │ └── scaling-plots.svg │ ├── test_get_legend.R │ ├── test_draw_.R │ ├── test_themes.R │ └── test_plot_grid.R └── testthat.R ├── .gitignore ├── inst └── extdata │ ├── cow.jpg │ └── logo.png ├── man ├── figures │ └── logo.png ├── gtable_squash_rows.Rd ├── gtable_squash_cols.Rd ├── gtable_remove_grobs.Rd ├── png_null_device.Rd ├── theme_nothing.Rd ├── get_title.Rd ├── draw_line.Rd ├── panel_border.Rd ├── get_y_axis.Rd ├── as_gtable.Rd ├── ggdraw.Rd ├── as_grob.Rd ├── cowplot-package.Rd ├── theme_map.Rd ├── get_panel.Rd ├── stamp.Rd ├── get_plot_component.Rd ├── theme_cowplot.Rd ├── draw_plot_label.Rd ├── draw_plot.Rd ├── ggsave2.Rd ├── draw_grob.Rd ├── background_grid.Rd ├── insert_xaxis_grob.Rd ├── get_legend.Rd ├── draw_text.Rd ├── set_null_device.Rd ├── draw_figure_label.Rd ├── rectangle_key_glyph.Rd ├── theme_minimal_grid.Rd ├── align_margin.Rd ├── align_plots.Rd ├── draw_label.Rd ├── draw_image.Rd ├── axis_canvas.Rd └── save_plot.Rd ├── pkgdown └── favicon │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ └── apple-touch-icon-180x180.png ├── R ├── utils_ggplot2.R ├── cowplot.R ├── setup.R ├── get_titles.R ├── get_axes.R ├── gtable.R ├── as_gtable.R ├── stamp.R ├── get_legend.R ├── get_panel.R └── get_plot_component.R ├── cran-comments.md ├── .Rbuildignore ├── cowplot.Rproj ├── TODO ├── revdep ├── cran.md └── README.md ├── ISSUE_TEMPLATE.md ├── _pkgdown.yml ├── .github └── workflows │ └── R-CMD-check.yaml ├── README.md ├── NAMESPACE ├── DESCRIPTION └── vignettes └── mixing_plot_frameworks.Rmd /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /tests/testthat/.gitignore: -------------------------------------------------------------------------------- 1 | Rplots.pdf 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Meta 2 | .Rproj.user 3 | .Rhistory 4 | .RData 5 | doc 6 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/logo.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/favicon.ico -------------------------------------------------------------------------------- /inst/extdata/cow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/inst/extdata/cow.jpg -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(cowplot) 3 | 4 | test_check("cowplot") 5 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/reference/p1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/p1.png -------------------------------------------------------------------------------- /docs/reference/p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/p2.png -------------------------------------------------------------------------------- /docs/reference/p3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/p3.pdf -------------------------------------------------------------------------------- /docs/reference/p4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/p4.pdf -------------------------------------------------------------------------------- /inst/extdata/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/inst/extdata/logo.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/Rplot002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot002.png -------------------------------------------------------------------------------- /docs/reference/Rplot003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot003.png -------------------------------------------------------------------------------- /docs/reference/Rplot004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot004.png -------------------------------------------------------------------------------- /docs/reference/Rplot005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot005.png -------------------------------------------------------------------------------- /docs/reference/Rplot006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot006.png -------------------------------------------------------------------------------- /docs/reference/Rplot007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot007.png -------------------------------------------------------------------------------- /docs/reference/Rplot008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot008.png -------------------------------------------------------------------------------- /docs/reference/Rplot009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/Rplot009.png -------------------------------------------------------------------------------- /docs/reference/add_sub-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/add_sub-1.png -------------------------------------------------------------------------------- /docs/reference/add_sub-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/add_sub-2.png -------------------------------------------------------------------------------- /docs/reference/add_sub-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/add_sub-3.png -------------------------------------------------------------------------------- /docs/reference/add_sub-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/add_sub-4.png -------------------------------------------------------------------------------- /docs/reference/as_grob-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/as_grob-1.png -------------------------------------------------------------------------------- /docs/reference/ggdraw-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/ggdraw-1.png -------------------------------------------------------------------------------- /docs/reference/stamp-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/stamp-1.png -------------------------------------------------------------------------------- /docs/reference/stamp-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/stamp-2.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /docs/reference/draw_grob-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_grob-1.png -------------------------------------------------------------------------------- /docs/reference/draw_line-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_line-1.png -------------------------------------------------------------------------------- /docs/reference/draw_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_plot-1.png -------------------------------------------------------------------------------- /docs/reference/draw_text-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_text-1.png -------------------------------------------------------------------------------- /docs/reference/draw_text-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_text-2.png -------------------------------------------------------------------------------- /docs/reference/get_panel-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_panel-1.png -------------------------------------------------------------------------------- /docs/reference/get_panel-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_panel-2.png -------------------------------------------------------------------------------- /docs/reference/get_title-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_title-1.png -------------------------------------------------------------------------------- /docs/reference/get_title-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_title-2.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-1.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-2.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-3.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-4.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-5.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-6.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-7.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-8.png -------------------------------------------------------------------------------- /docs/reference/plot_grid-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/plot_grid-9.png -------------------------------------------------------------------------------- /docs/reference/theme_map-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_map-1.png -------------------------------------------------------------------------------- /docs/reference/theme_map-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_map-2.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/reference/align_margin-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/align_margin-1.png -------------------------------------------------------------------------------- /docs/reference/align_plots-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/align_plots-1.png -------------------------------------------------------------------------------- /docs/reference/axis_canvas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/axis_canvas-1.png -------------------------------------------------------------------------------- /docs/reference/axis_canvas-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/axis_canvas-2.png -------------------------------------------------------------------------------- /docs/reference/axis_canvas-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/axis_canvas-3.png -------------------------------------------------------------------------------- /docs/reference/draw_image-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_image-1.png -------------------------------------------------------------------------------- /docs/reference/draw_image-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_image-2.png -------------------------------------------------------------------------------- /docs/reference/draw_image-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_image-3.png -------------------------------------------------------------------------------- /docs/reference/draw_image-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_image-4.png -------------------------------------------------------------------------------- /docs/reference/draw_label-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_label-1.png -------------------------------------------------------------------------------- /docs/reference/draw_label-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_label-2.png -------------------------------------------------------------------------------- /docs/reference/draw_label-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_label-3.png -------------------------------------------------------------------------------- /docs/reference/draw_label-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_label-4.png -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /docs/reference/get_legend-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-1.png -------------------------------------------------------------------------------- /docs/reference/get_legend-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-2.png -------------------------------------------------------------------------------- /docs/reference/get_legend-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-3.png -------------------------------------------------------------------------------- /docs/reference/get_legend-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-4.png -------------------------------------------------------------------------------- /docs/reference/get_legend-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-5.png -------------------------------------------------------------------------------- /docs/reference/get_legend-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_legend-6.png -------------------------------------------------------------------------------- /docs/reference/get_y_axis-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_y_axis-1.png -------------------------------------------------------------------------------- /docs/reference/get_y_axis-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_y_axis-2.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /docs/reference/theme_cowplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_cowplot-1.png -------------------------------------------------------------------------------- /docs/reference/theme_nothing-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_nothing-1.png -------------------------------------------------------------------------------- /docs/reference/background_grid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/background_grid-1.png -------------------------------------------------------------------------------- /docs/reference/draw_figure_label-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_figure_label-1.png -------------------------------------------------------------------------------- /docs/reference/draw_figure_label-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_figure_label-2.png -------------------------------------------------------------------------------- /docs/reference/draw_figure_label-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_figure_label-3.png -------------------------------------------------------------------------------- /docs/reference/draw_figure_label-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_figure_label-4.png -------------------------------------------------------------------------------- /docs/reference/draw_figure_label-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/draw_figure_label-5.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/reference/figures/cowplot-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/figures/cowplot-logo.png -------------------------------------------------------------------------------- /docs/reference/get_plot_component-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/get_plot_component-1.png -------------------------------------------------------------------------------- /docs/reference/rectangle_key_glyph-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/rectangle_key_glyph-1.png -------------------------------------------------------------------------------- /docs/reference/rectangle_key_glyph-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/rectangle_key_glyph-2.png -------------------------------------------------------------------------------- /docs/reference/theme_minimal_grid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_minimal_grid-1.png -------------------------------------------------------------------------------- /docs/reference/theme_minimal_grid-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_minimal_grid-2.png -------------------------------------------------------------------------------- /docs/reference/theme_minimal_grid-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/reference/theme_minimal_grid-3.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /R/utils_ggplot2.R: -------------------------------------------------------------------------------- 1 | # code that needed to be copied from ggplot2 2 | 3 | # @keyword internal 4 | is.waive <- function(x) inherits(x, "waiver") 5 | -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-4-2.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-5-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-5-2.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /docs/articles/themes_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/themes_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/plot_grid_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-2-2.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-3-2.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-1-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-1-3.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-1-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-1-4.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-2.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-3.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-4.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/shared_legends_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/aligning_plots_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /tests/testthat/helper-vdiffr.R: -------------------------------------------------------------------------------- 1 | expect_doppelganger <- function(title, fig, ...) { 2 | testthat::skip_if_not_installed("vdiffr") 3 | vdiffr::expect_doppelganger(title, fig, ...) 4 | } 5 | -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/drawing_with_on_plots_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-4-2.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-5-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-5-2.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkelab/cowplot/HEAD/docs/articles/mixing_plot_frameworks_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /tests/testthat/test_ggdraw.R: -------------------------------------------------------------------------------- 1 | context("ggdraw") 2 | 3 | test_that("basic ggdraw usage", { 4 | # empty ggdraw object 5 | g <- ggdraw() 6 | 7 | expect_true(is_ggplot(g)) 8 | 9 | # test proper scale limits on empty object 10 | build <- ggplot2::ggplot_build(g) 11 | limits <- build$layout$coord$limits 12 | expect_equal(limits$x, c(0, 1)) 13 | expect_equal(limits$y, c(0, 1)) 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.2' 2 | pkgdown: 2.1.3 3 | pkgdown_sha: ~ 4 | articles: 5 | aligning_plots: aligning_plots.html 6 | drawing_with_on_plots: drawing_with_on_plots.html 7 | introduction: introduction.html 8 | mixing_plot_frameworks: mixing_plot_frameworks.html 9 | plot_grid: plot_grid.html 10 | shared_legends: shared_legends.html 11 | themes: themes.html 12 | last_built: 2025-07-06T18:07Z 13 | -------------------------------------------------------------------------------- /tests/testthat/test_get_titles.R: -------------------------------------------------------------------------------- 1 | context("get_titles") 2 | 3 | test_that("get titles", { 4 | df <- data.frame(x = 1:3, y = 1:3) 5 | p <- ggplot(df, aes(x, y)) + geom_point() 6 | 7 | expect_null(get_title(p)) 8 | expect_null(get_subtitle(p)) 9 | 10 | p <- p + labs(title = "Title", subtitle = "Subtitle") 11 | 12 | expect_s3_class(get_title(p), "titleGrob") 13 | expect_s3_class(get_subtitle(p), "titleGrob") 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | Minor bug fixes for upcoming ggplot2 release. 2 | 3 | One package has a reverse dependency fail. They were informed three weeks ago 4 | and have not responded in any way: https://github.com/yuelyu21/SCIntRuler/issues/3 5 | 6 | ## Test environments 7 | 8 | * ubuntu 24.04.2, devel and release 9 | * windows, devel and release 10 | * macOS, release 11 | 12 | ## R CMD check results 13 | 14 | 0 errors | 0 warnings | 0 notes 15 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^_pkgdown\.yml$ 2 | ^docs$ 3 | ^.*\.Rproj$ 4 | ^\.Rproj\.user$ 5 | ^\.github$ 6 | ^\.codecov\.yml$ 7 | ^cran-comments\.md$ 8 | ^TODO$ 9 | ^ISSUE_TEMPLATE\.md$ 10 | ^vignettes/mixing_plot_frameworks.Rmd$ 11 | ^vignettes/themes.Rmd$ 12 | ^vignettes/plot_grid.Rmd$ 13 | ^vignettes/drawing_with_on_plots.Rmd$ 14 | ^vignettes/aligning_plots.Rmd$ 15 | ^vignettes/shared_legends.Rmd$ 16 | ^revdep$ 17 | ^pkgdown$ 18 | ^Meta$ 19 | ^CRAN-RELEASE$ 20 | ^CRAN-SUBMISSION$ 21 | -------------------------------------------------------------------------------- /man/gtable_squash_rows.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gtable.R 3 | \name{gtable_squash_rows} 4 | \alias{gtable_squash_rows} 5 | \title{Set the height of given rows to 0.} 6 | \usage{ 7 | gtable_squash_rows(table, rows) 8 | } 9 | \arguments{ 10 | \item{table}{The gtable on which to operate} 11 | 12 | \item{rows}{Numerical vector indicating the rows whose heights should be set to zero.} 13 | } 14 | \description{ 15 | Set the height of given rows to 0. 16 | } 17 | -------------------------------------------------------------------------------- /man/gtable_squash_cols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gtable.R 3 | \name{gtable_squash_cols} 4 | \alias{gtable_squash_cols} 5 | \title{Set the width of given columns to 0.} 6 | \usage{ 7 | gtable_squash_cols(table, cols) 8 | } 9 | \arguments{ 10 | \item{table}{The gtable on which to operate} 11 | 12 | \item{cols}{Numerical vector indicating the columns whose width should be set to zero.} 13 | } 14 | \description{ 15 | Set the width of given columns to 0. 16 | } 17 | -------------------------------------------------------------------------------- /cowplot.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: c8449121-eb8c-409e-8127-fb47040cefcb 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: Sweave 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /tests/testthat/test_get_panel.R: -------------------------------------------------------------------------------- 1 | context("get_panel") 2 | 3 | test_that("get panel", { 4 | df <- data.frame(x = 1:3, y = 1:3, z = factor(c("a", "b", "c"))) 5 | p <- ggplot(df, aes(x, y)) + geom_point() 6 | 7 | panel <- get_panel(p) 8 | 9 | expect_s3_class(panel, "gTree") 10 | expect_match(panel$name, "^panel-1\\.gTree\\.") 11 | 12 | # get_panel() returns just 1 unless specified 13 | facet_p <- p + facet_wrap(~z) 14 | expect_warning(get_panel(facet_p)) 15 | expect_type(get_panel(facet_p, return_all = TRUE), "list") 16 | }) 17 | 18 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Before 1.0 release: 2 | - Fix axis_canvas() 3 | - Add as_grob() function for gList 4 | - null devices should make temporary files and clean up after exit - may not be technically possible 5 | 6 | Things to fix or improve 7 | ============================= 8 | - more regression tests are needed. 9 | - write vignette on themes 10 | 11 | Ideas for further development 12 | ============================= 13 | - make a theme for individual plots and one for grouped plots (and one for faceted plots?), make sure that all default settings work well together. 14 | -------------------------------------------------------------------------------- /docs/articles/themes_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /tests/testthat/test_get_axes.R: -------------------------------------------------------------------------------- 1 | context("get_axes") 2 | 3 | test_that("get x and y axes", { 4 | df <- data.frame(x = 1:3, y = 1:3) 5 | p <- ggplot(df, aes(x, y)) + geom_point() 6 | 7 | expect_s3_class(get_x_axis(p), "gTree") 8 | expect_s3_class(get_y_axis(p), "gTree") 9 | expect_null(get_x_axis(p, position = "top")) 10 | expect_null(get_y_axis(p, position = "right")) 11 | expect_s3_class(get_y_axis(p + scale_y_continuous(position = "right"), position = "right"), "gTree") 12 | expect_s3_class(get_x_axis(p + scale_x_continuous(position = "top"), position = "top"), "gTree") 13 | 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /docs/articles/introduction_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/plot_grid_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/aligning_plots_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/shared_legends_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/drawing_with_on_plots_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/mixing_plot_frameworks_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /man/gtable_remove_grobs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gtable.R 3 | \name{gtable_remove_grobs} 4 | \alias{gtable_remove_grobs} 5 | \title{Remove named elements from gtable} 6 | \usage{ 7 | gtable_remove_grobs(table, names, ...) 8 | } 9 | \arguments{ 10 | \item{table}{The table from which grobs should be removed} 11 | 12 | \item{names}{A character vector of the grob names (as listed in \code{table$layout}) 13 | that should be removed} 14 | 15 | \item{...}{Other parameters passed through to \code{gtable_filter}.} 16 | } 17 | \description{ 18 | Remove named elements from gtable 19 | } 20 | -------------------------------------------------------------------------------- /R/cowplot.R: -------------------------------------------------------------------------------- 1 | #' Streamlined Plot Theme and Plot Annotations for 'ggplot2' 2 | #' 3 | #' Provides various features that help with creating publication-quality 4 | #' figures with 'ggplot2', such as a set of themes, functions to align 5 | #' plots and arrange them into complex compound figures, and functions 6 | #' that make it easy to annotate plots and or mix plots with images. The 7 | #' package was originally written for internal use in the Wilke lab, 8 | #' hence the name (Claus O. Wilke's plot package). It has also been used 9 | #' extensively in the book Fundamentals of Data Visualization. 10 | #' 11 | #' @import ggplot2 12 | #' @import grid 13 | #' @import rlang 14 | #' @keywords internal 15 | "_PACKAGE" 16 | 17 | -------------------------------------------------------------------------------- /R/setup.R: -------------------------------------------------------------------------------- 1 | # ************************************************* 2 | # Setup 3 | # ************************************************* 4 | 5 | .onAttach <- function(libname, pkgname) { 6 | # switch the default theme to theme_cowplot 7 | # ggplot2::theme_set(theme_cowplot()) 8 | #packageStartupMessage("\n********************************************************") 9 | #packageStartupMessage("Note: As of version 1.0.0, cowplot does not change the") 10 | #packageStartupMessage(" default ggplot2 theme anymore. To recover the previous") 11 | #packageStartupMessage(" behavior, execute:\n theme_set(theme_cowplot())") 12 | #packageStartupMessage("********************************************************\n") 13 | } 14 | -------------------------------------------------------------------------------- /R/get_titles.R: -------------------------------------------------------------------------------- 1 | #' Get plot titles 2 | #' 3 | #' These functions extract just the titles from a ggplot. `get_title()` pulls 4 | #' the title, while `get_subtitle()` pulls the subtitle. 5 | #' 6 | #' @param plot A ggplot or gtable. 7 | #' @examples 8 | #' library(ggplot2) 9 | #' 10 | #' p <- ggplot(mpg, aes(displ, cty)) + 11 | #' geom_point() + 12 | #' labs( 13 | #' title = "Plot title", 14 | #' subtitle = "Plot subtitle" 15 | #' ) 16 | #' ggdraw(get_title(p)) 17 | #' ggdraw(get_subtitle(p)) 18 | #' 19 | #' @export 20 | get_title <- function(plot) { 21 | get_plot_component(plot, "^title") 22 | } 23 | 24 | #' @rdname get_title 25 | #' @export 26 | get_subtitle <- function(plot) { 27 | get_plot_component(plot, "subtitle") 28 | } 29 | -------------------------------------------------------------------------------- /man/png_null_device.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/set_null_device.R 3 | \name{png_null_device} 4 | \alias{png_null_device} 5 | \alias{pdf_null_device} 6 | \alias{cairo_null_device} 7 | \alias{agg_null_device} 8 | \title{Null devices} 9 | \usage{ 10 | png_null_device(width, height) 11 | 12 | pdf_null_device(width, height) 13 | 14 | cairo_null_device(width, height) 15 | 16 | agg_null_device(width, height) 17 | } 18 | \arguments{ 19 | \item{width}{Device width in inch} 20 | 21 | \item{height}{Device height in inch} 22 | } 23 | \description{ 24 | Null devices to be used when rendering graphics in the background. See 25 | \code{\link[=set_null_device]{set_null_device()}} for details. 26 | } 27 | -------------------------------------------------------------------------------- /man/theme_nothing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{theme_nothing} 4 | \alias{theme_nothing} 5 | \title{Create a completely empty theme} 6 | \usage{ 7 | theme_nothing(font_size = 14, font_family = "", rel_small = 12/14) 8 | } 9 | \arguments{ 10 | \item{font_size}{Overall font size. Default is 14.} 11 | 12 | \item{font_family}{Base font family.} 13 | 14 | \item{rel_small}{Relative size of small text} 15 | } 16 | \value{ 17 | The theme. 18 | } 19 | \description{ 20 | The theme created by this function shows nothing but the plot panel. 21 | } 22 | \examples{ 23 | library(ggplot2) 24 | 25 | ggplot(mtcars, aes(disp, mpg, color = cyl)) + 26 | geom_point() + 27 | theme_nothing() 28 | } 29 | -------------------------------------------------------------------------------- /revdep/cran.md: -------------------------------------------------------------------------------- 1 | ## revdepcheck results 2 | 3 | We checked 460 reverse dependencies (332 from CRAN + 128 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package. 4 | 5 | * We saw 2 new problems 6 | * We failed to check 7 packages 7 | 8 | Issues with CRAN packages are summarised below. 9 | 10 | ### New problems 11 | (This reports the first line of each new failure) 12 | 13 | * BeeBDC 14 | checking tests ... 15 | 16 | * SCIntRuler 17 | checking running R code from vignettes ... 18 | 19 | ### Failed to check 20 | 21 | * bartMan (NA) 22 | * clustTMB (NA) 23 | * LipinskiFilters (NA) 24 | * TestAnaAPP (NA) 25 | * text (NA) 26 | * tidybayes (NA) 27 | * valse (NA) 28 | -------------------------------------------------------------------------------- /man/get_title.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_titles.R 3 | \name{get_title} 4 | \alias{get_title} 5 | \alias{get_subtitle} 6 | \title{Get plot titles} 7 | \usage{ 8 | get_title(plot) 9 | 10 | get_subtitle(plot) 11 | } 12 | \arguments{ 13 | \item{plot}{A ggplot or gtable.} 14 | } 15 | \description{ 16 | These functions extract just the titles from a ggplot. \code{get_title()} pulls 17 | the title, while \code{get_subtitle()} pulls the subtitle. 18 | } 19 | \examples{ 20 | library(ggplot2) 21 | 22 | p <- ggplot(mpg, aes(displ, cty)) + 23 | geom_point() + 24 | labs( 25 | title = "Plot title", 26 | subtitle = "Plot subtitle" 27 | ) 28 | ggdraw(get_title(p)) 29 | ggdraw(get_subtitle(p)) 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Issues are meant to report bugs or request features. If you have questions about how to correctly use this package, please don't use the issue system. Such questions can be asked on stackoverflow https://stackoverflow.com/ or the RStudio community https://community.rstudio.com/. If you are not sure where to go, please try https://stackoverflow.com/ first. 2 | 3 | Issues must contain reproducible code examples. Please use the reprex package to create your example (see here: http://reprex.tidyverse.org/). Issues without reprex may be closed without comment. 4 | 5 | Please delete these instructions after you have read them. 6 | 7 | ------ 8 | 9 | Brief description of the problem or desired feature. 10 | 11 | ```{r} 12 | # insert reprex here 13 | ``` -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /man/draw_line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_line} 4 | \alias{draw_line} 5 | \title{Draw a line from connected points} 6 | \usage{ 7 | draw_line(x, y, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Vector of x coordinates.} 11 | 12 | \item{y}{Vector of y coordinates.} 13 | 14 | \item{...}{geom_path parameters such as \code{colour}, \code{alpha}, \code{size}, etc.} 15 | } 16 | \description{ 17 | Provide a sequence of x values and accompanying y values to draw a line on a plot. 18 | } 19 | \details{ 20 | This is a convenience function, providing a wrapper around \code{\link[ggplot2:geom_path]{ggplot2::geom_path()}}. 21 | } 22 | \examples{ 23 | ggdraw() + 24 | draw_line( 25 | x = c(0.2, 0.7, 0.7, 0.3), 26 | y = c(0.1, 0.3, 0.9, 0.8), 27 | color = "blue", size = 2 28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /man/panel_border.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{panel_border} 4 | \alias{panel_border} 5 | \title{Add/remove the panel border in a ggplot2 plot} 6 | \usage{ 7 | panel_border(color = "grey85", size = 1, linetype = 1, remove = FALSE, colour) 8 | } 9 | \arguments{ 10 | \item{color, colour}{The color of the border.} 11 | 12 | \item{size}{Size. Needs to be twice as large as desired outcome when panel clipping 13 | is on (the default).} 14 | 15 | \item{linetype}{Line type.} 16 | 17 | \item{remove}{If \code{TRUE}, removes the current panel border.} 18 | } 19 | \description{ 20 | This function provides a simple way to modify the panel border in ggplot2. It 21 | doesn't do anything that can't be done just the same with \code{\link[ggplot2:theme]{ggplot2::theme()}}. However, it 22 | saves some typing. 23 | } 24 | -------------------------------------------------------------------------------- /man/get_y_axis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_axes.R 3 | \name{get_y_axis} 4 | \alias{get_y_axis} 5 | \alias{get_x_axis} 6 | \title{Get plot axes} 7 | \usage{ 8 | get_y_axis(plot, position = c("left", "right")) 9 | 10 | get_x_axis(plot, position = c("bottom", "top")) 11 | } 12 | \arguments{ 13 | \item{plot}{A ggplot or gtable.} 14 | 15 | \item{position}{Which side of the plot is the axis on? For the x-axis, this 16 | can be "top" or "bottom", and for the y-axis, it can be "left" or "right".} 17 | } 18 | \description{ 19 | These functions extract just the axes from a ggplot. \code{get_y_axis()} pulls 20 | the y-axis, while \code{get_x_axis()} pulls the x-axis. 21 | } 22 | \examples{ 23 | library(ggplot2) 24 | 25 | p <- ggplot(mpg, aes(displ, cty)) + 26 | geom_point() 27 | 28 | ggdraw(get_y_axis(p)) 29 | p <- p + scale_x_continuous(position = "top") 30 | ggdraw(get_x_axis(p, position = "top")) 31 | 32 | } 33 | -------------------------------------------------------------------------------- /man/as_gtable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/as_gtable.R 3 | \name{as_gtable} 4 | \alias{as_gtable} 5 | \alias{plot_to_gtable} 6 | \title{Convert plot or other graphics object into a gtable} 7 | \usage{ 8 | as_gtable(plot) 9 | 10 | plot_to_gtable(plot) 11 | } 12 | \arguments{ 13 | \item{plot}{The plot or other graphics object to convert into a gtable. Here, \code{plot} can be 14 | any object handled by \code{\link[=as_grob]{as_grob()}}.} 15 | } 16 | \description{ 17 | This function does its best attempt to take whatever you provide it and turn it into a gtable. 18 | It is primarily meant to convert ggplot plots into gtables, but it will also take any grid 19 | object (grob), a recorded R base plot, or a function that generates an R base plot. 20 | } 21 | \details{ 22 | To convert ggplot plots, the function needs to use a null graphics device. This can be set 23 | with \code{\link[=set_null_device]{set_null_device()}}. 24 | } 25 | -------------------------------------------------------------------------------- /man/ggdraw.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{ggdraw} 4 | \alias{ggdraw} 5 | \title{Set up a drawing layer on top of a ggplot} 6 | \usage{ 7 | ggdraw(plot = NULL, xlim = c(0, 1), ylim = c(0, 1), clip = "off") 8 | } 9 | \arguments{ 10 | \item{plot}{The plot to use as a starting point. Can be a ggplot2 plot, an arbitrary 11 | grob or gtable, or a recorded base-R plot, as in \code{\link[=as_grob]{as_grob()}}.} 12 | 13 | \item{xlim}{The x-axis limits for the drawing layer.} 14 | 15 | \item{ylim}{The y-axis limits for the drawing layer.} 16 | 17 | \item{clip}{Should drawing be clipped to the set limits? The default is no ("off").} 18 | } 19 | \description{ 20 | Set up a drawing layer on top of a ggplot. 21 | } 22 | \examples{ 23 | library(ggplot2) 24 | 25 | p <- ggplot(mpg, aes(displ, cty)) + 26 | geom_point() + 27 | theme_minimal_grid() 28 | ggdraw(p) + draw_label("Draft", colour = "#80404080", size = 120, angle = 45) 29 | } 30 | -------------------------------------------------------------------------------- /man/as_grob.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/as_grob.R 3 | \name{as_grob} 4 | \alias{as_grob} 5 | \title{Convert a base plot or a ggplot2 plot into a grob} 6 | \usage{ 7 | as_grob(plot, device = NULL) 8 | } 9 | \arguments{ 10 | \item{plot}{The plot to convert} 11 | 12 | \item{device}{A function that creates an appropriate null device. See \code{\link[=set_null_device]{set_null_device()}} 13 | for details. If set to \code{NULL}, will use the cowplot-wide default.} 14 | } 15 | \description{ 16 | This function does its best attempt to take whatever you provide it and turn it into a grob. 17 | It is primarily meant to convert ggplot plots into grobs, but it will also take any grid 18 | object (grob), a recorded base R plot, a formula specifying a base R plot, a function that 19 | generates a base R plot, or a trellis object. 20 | } 21 | \examples{ 22 | library(grid) 23 | x <- 1:10 24 | y <- (1:10)^2 25 | 26 | p <- ~plot(x, y) 27 | grid.newpage() 28 | grid.draw(as_grob(p)) 29 | } 30 | -------------------------------------------------------------------------------- /tests/testthat/test_key_glyph.R: -------------------------------------------------------------------------------- 1 | context("key_glyph") 2 | 3 | # ------------------------------------ 4 | # visual tests 5 | 6 | test_that("key glyphs", { 7 | set.seed(1233) 8 | df <- data.frame( 9 | x = sample(letters[1:2], 10, TRUE), 10 | y = rnorm(10) 11 | ) 12 | 13 | p1 <- ggplot(df, aes(x, y, color = x)) + 14 | # use geom_point() for missing linetype, size 15 | geom_point( 16 | key_glyph = rectangle_key_glyph(fill = color, padding = margin(3, 3, 3, 3)) 17 | ) 18 | 19 | expect_doppelganger("rectangle key glyph, color used as fill", 20 | p1 + theme_map() # add theme_map() for plot title 21 | ) 22 | 23 | p2 <- ggplot(df, aes(x, y, color = x)) + 24 | geom_boxplot( 25 | key_glyph = circle_key_glyph( 26 | fill = color, 27 | color = "black", linetype = 3, size = 0.3, 28 | padding = margin(2, 2, 2, 2) 29 | ) 30 | ) 31 | 32 | expect_doppelganger("circle key glyph, color used as fill", 33 | p2 + theme_map() # add theme_map() for plot title 34 | ) 35 | 36 | }) 37 | 38 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | destination: docs 2 | 3 | reference: 4 | - title: Plot composition 5 | desc: Arranging and aligning plots 6 | contents: 7 | - align_margin 8 | - align_plots 9 | - plot_grid 10 | 11 | - title: Drawing 12 | desc: Place elements on the canvas 13 | contents: 14 | - starts_with("draw_") 15 | - starts_with("stamp_") 16 | - ggdraw 17 | - add_sub 18 | - axis_canvas 19 | 20 | - title: Themes 21 | desc: Modify plot appearance 22 | contents: 23 | - starts_with("theme_") 24 | - background_grid 25 | - panel_border 26 | - rectangle_key_glyph 27 | - circle_key_glyph 28 | 29 | - title: Get methods 30 | desc: Retrieve elements of a plot 31 | contents: 32 | - starts_with("get_") 33 | 34 | - title: Grobs 35 | desc: Manipulate and convert grobs 36 | contents: 37 | - starts_with("gtable_") 38 | - starts_with("as_") 39 | - insert_xaxis_grob 40 | - insert_yaxis_grob 41 | 42 | - title: Output 43 | desc: Render figures to an output 44 | contents: 45 | - ggsave2 46 | - save_plot 47 | - png_null_device 48 | - set_null_device 49 | -------------------------------------------------------------------------------- /R/get_axes.R: -------------------------------------------------------------------------------- 1 | #' Get plot axes 2 | #' 3 | #' These functions extract just the axes from a ggplot. `get_y_axis()` pulls 4 | #' the y-axis, while `get_x_axis()` pulls the x-axis. 5 | #' 6 | #' @param plot A ggplot or gtable. 7 | #' @param position Which side of the plot is the axis on? For the x-axis, this 8 | #' can be "top" or "bottom", and for the y-axis, it can be "left" or "right". 9 | #' @examples 10 | #' library(ggplot2) 11 | #' 12 | #' p <- ggplot(mpg, aes(displ, cty)) + 13 | #' geom_point() 14 | #' 15 | #' ggdraw(get_y_axis(p)) 16 | #' p <- p + scale_x_continuous(position = "top") 17 | #' ggdraw(get_x_axis(p, position = "top")) 18 | #' 19 | #' @export 20 | get_y_axis <- function(plot, position = c("left", "right")) { 21 | position <- switch(match.arg(position), "left" = "l", "right" = "r") 22 | get_plot_component(plot, paste0("axis-", position)) 23 | } 24 | 25 | #' @rdname get_y_axis 26 | #' @export 27 | get_x_axis <- function(plot, position = c("bottom", "top")) { 28 | position <- switch(match.arg(position), "bottom" = "b", "top" = "t") 29 | get_plot_component(plot, paste0("axis-", position)) 30 | } 31 | -------------------------------------------------------------------------------- /tests/testthat/test_plot_components.R: -------------------------------------------------------------------------------- 1 | context("test_plot_components") 2 | 3 | test_that("plot components", { 4 | df <- data.frame(x = 1:3, y = 1:3, z = factor(c("a", "b", "c"))) 5 | p <- ggplot(df, aes(x, y, color = z)) + geom_point() 6 | 7 | component_names <- c( 8 | "background", "spacer", "axis-l", "spacer", "axis-t", "panel", 9 | "axis-b", "spacer", "axis-r", "spacer", "xlab-t", "xlab-b", "ylab-l", 10 | "ylab-r", "guide-box", "subtitle", "title", "caption", "tag" 11 | ) 12 | if (inherits(guide_legend(), "Guide")) { # proxy testing for ggplot2 3.5.0+ 13 | component_names <- setdiff(component_names, c("guide-box", "tag")) 14 | component_names <- union( 15 | component_names, 16 | paste0("guide-box-", c("left", "right", "top", "bottom", "inside")) 17 | ) 18 | } 19 | 20 | expect_type(plot_component_names(p), "character") 21 | expect_true(all(component_names %in% plot_component_names(p))) 22 | 23 | x_label <- get_plot_component(p, "xlab-b") 24 | expect_s3_class(x_label, "grob") 25 | expect_null(get_plot_component(p, "no-matching-grob")) 26 | 27 | expect_type(plot_components(p), "list") 28 | }) 29 | -------------------------------------------------------------------------------- /man/cowplot-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cowplot.R 3 | \docType{package} 4 | \name{cowplot-package} 5 | \alias{cowplot} 6 | \alias{cowplot-package} 7 | \title{Streamlined Plot Theme and Plot Annotations for 'ggplot2'} 8 | \description{ 9 | Provides various features that help with creating publication-quality 10 | figures with 'ggplot2', such as a set of themes, functions to align 11 | plots and arrange them into complex compound figures, and functions 12 | that make it easy to annotate plots and or mix plots with images. The 13 | package was originally written for internal use in the Wilke lab, 14 | hence the name (Claus O. Wilke's plot package). It has also been used 15 | extensively in the book Fundamentals of Data Visualization. 16 | } 17 | \seealso{ 18 | Useful links: 19 | \itemize{ 20 | \item \url{https://wilkelab.org/cowplot/} 21 | \item Report bugs at \url{https://github.com/wilkelab/cowplot/issues} 22 | } 23 | 24 | } 25 | \author{ 26 | \strong{Maintainer}: Claus O. Wilke \email{wilke@austin.utexas.edu} (\href{https://orcid.org/0000-0002-7470-9261}{ORCID}) 27 | 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /man/theme_map.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{theme_map} 4 | \alias{theme_map} 5 | \title{Create a theme for map plotting} 6 | \usage{ 7 | theme_map( 8 | font_size = 14, 9 | font_family = "", 10 | line_size = 0.5, 11 | rel_small = 12/14, 12 | rel_tiny = 11/14, 13 | rel_large = 16/14 14 | ) 15 | } 16 | \arguments{ 17 | \item{font_size}{Overall font size. Default is 14.} 18 | 19 | \item{font_family}{Base font family.} 20 | 21 | \item{line_size}{Line size for axis lines.} 22 | 23 | \item{rel_small}{Relative size of small text (e.g., axis tick labels)} 24 | 25 | \item{rel_tiny}{Relative size of tiny text (e.g., caption)} 26 | 27 | \item{rel_large}{Relative size of large text (e.g., title)} 28 | } 29 | \value{ 30 | The theme. 31 | } 32 | \description{ 33 | The theme created by this function is useful for plotting maps with cowplot default sizing. 34 | } 35 | \examples{ 36 | library(ggplot2) 37 | library(maps) 38 | 39 | usa_data = map_data("usa") 40 | ggplot(usa_data, aes(long, lat, fill = region)) + 41 | geom_polygon() + theme_map() 42 | ggplot(usa_data, aes(long, lat, fill = region)) + 43 | facet_wrap(~region, scales = "free") + 44 | geom_polygon() + theme_map() 45 | } 46 | -------------------------------------------------------------------------------- /R/gtable.R: -------------------------------------------------------------------------------- 1 | #' Remove named elements from gtable 2 | #' 3 | #' @param table The table from which grobs should be removed 4 | #' @param names A character vector of the grob names (as listed in \code{table$layout}) 5 | #' that should be removed 6 | #' @param ... Other parameters passed through to \code{gtable_filter}. 7 | #' @export 8 | gtable_remove_grobs <- function(table, names, ...) 9 | { 10 | kept_names <- table$layout$name[!(table$layout$name %in% names)] 11 | gtable::gtable_filter(table, paste(kept_names, sep="", collapse="|"), ...) 12 | } 13 | 14 | #' Set the height of given rows to 0. 15 | #' 16 | #' @param table The gtable on which to operate 17 | #' @param rows Numerical vector indicating the rows whose heights should be set to zero. 18 | #' @export 19 | gtable_squash_rows <- function(table, rows) 20 | { 21 | lapply(rows, function(x){ table$heights[[x]] <<- grid::unit(0, "in")}) 22 | table 23 | } 24 | 25 | #' Set the width of given columns to 0. 26 | #' 27 | #' @param table The gtable on which to operate 28 | #' @param cols Numerical vector indicating the columns whose width should be set to zero. 29 | #' @export 30 | gtable_squash_cols <- function(table, cols) 31 | { 32 | lapply(cols, function(x){ table$widths[[x]] <<- grid::unit(0, "in")}) 33 | table 34 | } 35 | -------------------------------------------------------------------------------- /man/get_panel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_panel.R 3 | \name{get_panel} 4 | \alias{get_panel} 5 | \alias{get_panel_component} 6 | \title{Retrieve the panel or part of a panel of a plot} 7 | \usage{ 8 | get_panel(plot, panel = NULL, return_all = FALSE) 9 | 10 | get_panel_component(panel, pattern) 11 | } 12 | \arguments{ 13 | \item{plot}{A ggplot or gtable from which to retrieve the panel} 14 | 15 | \item{panel}{An integer indicating which panel to pull. ggplot orders panels 16 | column-wise, so this is in order from the top left down.} 17 | 18 | \item{return_all}{If there is more than one panel, should all be returned 19 | as a list? Default is \code{FALSE}.} 20 | 21 | \item{pattern}{the name of the component} 22 | } 23 | \value{ 24 | A gtable object holding the panel(s) or a grob of the component 25 | } 26 | \description{ 27 | \code{get_panel()} extracts just the main panel from a ggplot or a specified panel 28 | in a faceted plot. \code{get_panel_component()} extracts components from the 29 | panel, such as geoms. 30 | } 31 | \examples{ 32 | library(ggplot2) 33 | 34 | p <- ggplot(mpg, aes(displ, cty)) + geom_point() 35 | plot_panel <- get_panel(p) 36 | ggdraw(plot_panel) 37 | 38 | ggdraw(get_panel_component(plot_panel, "geom_point")) 39 | 40 | } 41 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/draw_/label-color-taken-from-theme.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | red label 22 | Label color taken from theme 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/draw_/label-color-specified-w-uk-spelling.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | blue label 22 | Label color specified w/ UK spelling 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/draw_/label-color-specified-w-us-spelling.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | blue label 22 | Label color specified w/ US spelling 23 | 24 | 25 | -------------------------------------------------------------------------------- /man/stamp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamp.R 3 | \name{stamp} 4 | \alias{stamp} 5 | \alias{stamp_good} 6 | \alias{stamp_bad} 7 | \alias{stamp_wrong} 8 | \alias{stamp_ugly} 9 | \title{Stamp plots with a label, such as good, bad, or ugly.} 10 | \usage{ 11 | stamp( 12 | p, 13 | label, 14 | color = "black", 15 | alpha = 1, 16 | vjust = 1.1, 17 | hjust = 1, 18 | size = 14, 19 | family = "", 20 | fontface = "bold", 21 | clip = "on", 22 | colour 23 | ) 24 | 25 | stamp_good(p, ...) 26 | 27 | stamp_bad(p, ...) 28 | 29 | stamp_wrong(p, ...) 30 | 31 | stamp_ugly(p, ...) 32 | } 33 | \arguments{ 34 | \item{p}{The plot to stamp} 35 | 36 | \item{label}{The text label used for the stamp} 37 | 38 | \item{color, colour}{The color of the stamp} 39 | 40 | \item{alpha}{Transparency level of the stamp} 41 | 42 | \item{hjust, vjust}{Horizontal and vertical adjustment of the label} 43 | 44 | \item{size}{Font size} 45 | 46 | \item{family}{Font family} 47 | 48 | \item{fontface}{Font face} 49 | 50 | \item{clip}{Should figure be clipped (default is "on")} 51 | 52 | \item{...}{Arguments handed off to \code{stamp()}.} 53 | } 54 | \description{ 55 | Stamp plots with a label, such as good, bad, or ugly. 56 | } 57 | \examples{ 58 | library(ggplot2) 59 | 60 | p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 61 | geom_point(aes(color = factor(Petal.Width))) 62 | 63 | stamp_bad(p + guides(color = "none")) 64 | stamp_ugly(p) 65 | } 66 | -------------------------------------------------------------------------------- /R/as_gtable.R: -------------------------------------------------------------------------------- 1 | #' Convert plot or other graphics object into a gtable 2 | #' 3 | #' This function does its best attempt to take whatever you provide it and turn it into a gtable. 4 | #' It is primarily meant to convert ggplot plots into gtables, but it will also take any grid 5 | #' object (grob), a recorded R base plot, or a function that generates an R base plot. 6 | #' 7 | #' To convert ggplot plots, the function needs to use a null graphics device. This can be set 8 | #' with [set_null_device()]. 9 | #' 10 | #' @param plot The plot or other graphics object to convert into a gtable. Here, `plot` can be 11 | #' any object handled by [`as_grob()`]. 12 | #' @export 13 | as_gtable <- function(plot) { 14 | UseMethod("as_gtable") 15 | } 16 | 17 | #' @export 18 | as_gtable.gtable <- function(plot) { 19 | # gtables don't have to be converted 20 | plot 21 | } 22 | 23 | #' @export 24 | as_gtable.grob <- function(plot) { 25 | # we can handle basic grobs of any kind by wrapping them into a gtable 26 | u <- grid::unit(1, "null") 27 | gt <- gtable::gtable_col(NULL, list(plot), u, u) 28 | # fix gtable clip setting 29 | gt$layout$clip <- "inherit" 30 | gt 31 | } 32 | 33 | #' @export 34 | as_gtable.default <- function(plot) { 35 | # hope that as_grob() function can produce a grob 36 | grob <- as_grob(plot) 37 | as_gtable(grob) 38 | } 39 | 40 | #' @rdname as_gtable 41 | #' @export 42 | plot_to_gtable <- function(plot) { 43 | # this version is deprecated 44 | UseMethod("as_gtable") 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macos-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | 26 | env: 27 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 28 | R_KEEP_PKG_SOURCE: yes 29 | 30 | steps: 31 | - uses: actions/checkout@v3 32 | 33 | - uses: r-lib/actions/setup-pandoc@v2 34 | 35 | - uses: r-lib/actions/setup-r@v2 36 | with: 37 | r-version: ${{ matrix.config.r }} 38 | http-user-agent: ${{ matrix.config.http-user-agent }} 39 | use-public-rspm: true 40 | 41 | - uses: r-lib/actions/setup-r-dependencies@v2 42 | with: 43 | extra-packages: any::rcmdcheck 44 | needs: check 45 | 46 | - uses: r-lib/actions/check-r-package@v2 47 | with: 48 | upload-snapshots: true 49 | 50 | -------------------------------------------------------------------------------- /man/get_plot_component.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_plot_component.R 3 | \name{get_plot_component} 4 | \alias{get_plot_component} 5 | \alias{plot_component_names} 6 | \alias{plot_components} 7 | \title{Get plot components} 8 | \usage{ 9 | get_plot_component(plot, pattern, return_all = NA) 10 | 11 | plot_component_names(plot) 12 | 13 | plot_components(plot) 14 | } 15 | \arguments{ 16 | \item{plot}{A ggplot or gtable to extract from.} 17 | 18 | \item{pattern}{The name of the component.} 19 | 20 | \item{return_all}{If there is more than one component, should all be returned 21 | as a list? Default is \code{NA}, which returns the first component with a warning. 22 | \code{TRUE} returns all components. \code{FALSE} returns the first without warning.} 23 | } 24 | \value{ 25 | A grob or list of grobs (\code{get_plot_component()}, \code{plot_components()}) 26 | or a character vector (\code{plot_component_names()}) 27 | } 28 | \description{ 29 | Extract plot components from a ggplot or gtable. \code{get_plot_component()} 30 | extracts specific grobs or a list of grobs. Note that it omits \code{zeroGrob}s and 31 | returns \code{NULL} if there is no non-zero grob to return. \code{plot_component_names()} 32 | provides the names of the components in the plot. \code{plot_components()} returns all 33 | components as a list. 34 | } 35 | \examples{ 36 | library(ggplot2) 37 | 38 | p <- ggplot(mpg, aes(displ, cty)) + geom_point() 39 | ggdraw(get_plot_component(p, "ylab-l")) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /man/theme_cowplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{theme_cowplot} 4 | \alias{theme_cowplot} 5 | \alias{theme_half_open} 6 | \title{Create the default cowplot theme} 7 | \usage{ 8 | theme_cowplot( 9 | font_size = 14, 10 | font_family = "", 11 | line_size = 0.5, 12 | rel_small = 12/14, 13 | rel_tiny = 11/14, 14 | rel_large = 16/14 15 | ) 16 | 17 | theme_half_open( 18 | font_size = 14, 19 | font_family = "", 20 | line_size = 0.5, 21 | rel_small = 12/14, 22 | rel_tiny = 11/14, 23 | rel_large = 16/14 24 | ) 25 | } 26 | \arguments{ 27 | \item{font_size}{Overall font size.} 28 | 29 | \item{font_family}{Font family for plot title, axis titles and labels, legend texts, etc.} 30 | 31 | \item{line_size}{Line size for axis lines.} 32 | 33 | \item{rel_small}{Relative size of small text (e.g., axis tick labels)} 34 | 35 | \item{rel_tiny}{Relative size of tiny text (e.g., caption)} 36 | 37 | \item{rel_large}{Relative size of large text (e.g., title)} 38 | } 39 | \value{ 40 | The theme. 41 | } 42 | \description{ 43 | The default cowplot theme, with a simple half-open frame and no grid. This theme 44 | used to be set by default after loading the cowplot package, but this is no longer 45 | the case. 46 | } 47 | \details{ 48 | Both \code{theme_cowplot()} and \code{theme_half_open()} provide exactly the same styling. 49 | } 50 | \examples{ 51 | library(ggplot2) 52 | 53 | ggplot(mtcars, aes(disp, mpg)) + 54 | geom_point() + 55 | theme_cowplot(font_size = 12) 56 | } 57 | -------------------------------------------------------------------------------- /man/draw_plot_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_plot_label} 4 | \alias{draw_plot_label} 5 | \title{Add a label to a plot} 6 | \usage{ 7 | draw_plot_label( 8 | label, 9 | x = 0, 10 | y = 1, 11 | hjust = -0.5, 12 | vjust = 1.5, 13 | size = 16, 14 | fontface = "bold", 15 | family = NULL, 16 | color = NULL, 17 | colour, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{label}{String (or vector of strings) to be drawn as the label.} 23 | 24 | \item{x}{The x position (or vector thereof) of the label(s).} 25 | 26 | \item{y}{The y position (or vector thereof) of the label(s).} 27 | 28 | \item{hjust}{Horizontal adjustment.} 29 | 30 | \item{vjust}{Vertical adjustment.} 31 | 32 | \item{size}{Font size of the label to be drawn.} 33 | 34 | \item{fontface}{Font face of the label to be drawn.} 35 | 36 | \item{family}{(optional) Font family of the plot labels. If not provided, is taken from the current theme.} 37 | 38 | \item{color, colour}{(optional) Color of the plot labels. If not provided, is taken from the current theme.} 39 | 40 | \item{...}{Other arguments to be handed to \code{draw_text}.} 41 | } 42 | \description{ 43 | This function adds a plot label to the upper left corner of a graph (or an arbitrarily specified position). It takes all the same parameters 44 | as \code{draw_text}, but has defaults that make it convenient to label graphs with letters A, B, C, etc. Just like \code{draw_text()}, 45 | it can handle vectors of labels with associated coordinates. 46 | } 47 | -------------------------------------------------------------------------------- /tests/testthat/test_get_legend.R: -------------------------------------------------------------------------------- 1 | context("get_legend") 2 | 3 | # helper code to dig through grob trees to extract the title of a legend 4 | extract_legend_title <- function(l) { 5 | grbs <- l$grobs[[1]]$grobs 6 | # grob holding legend title is the penultimate one 7 | g <- grbs[[length(grbs) - 1]] 8 | # return label 9 | g$children[[1]]$label 10 | } 11 | 12 | 13 | test_that("get legend", { 14 | df <- data.frame(x = 1:3, y = 1:3, z = factor(c("a", "b", "c"))) 15 | p <- ggplot(df, aes(x, y, color = z)) + geom_point() 16 | 17 | l <- get_legend(p) 18 | 19 | expect_s3_class(l, "gtable") 20 | expect_equal(l$name, "guide-box") 21 | 22 | # return null legend if no legend 23 | expect_null(get_legend(p + theme(legend.position = "none"))) 24 | 25 | # plot with multiple legends 26 | q <- p + 27 | aes(shape = 'a') + 28 | guides( 29 | color = guide_legend(position = "inside"), 30 | shape = guide_legend(position = "bottom") 31 | ) 32 | 33 | 34 | ## these tests are not reliable across different ggplot2 and R versions 35 | ## as of this writing; try again later 36 | #l <- get_legend(q, "bottom") 37 | #expect_equal(extract_legend_title(l), "shape") # bottom legend is called "shape" 38 | #l <- get_legend(q, "inside") 39 | #expect_equal(extract_legend_title(l), "z") # inside legend is called "z" 40 | 41 | # top, right, left don't exist 42 | l <- get_legend(q, "top") 43 | expect_null(l) 44 | l <- get_legend(q, "right") 45 | expect_null(l) 46 | l <- get_legend(q, "left") 47 | expect_null(l) 48 | }) 49 | 50 | -------------------------------------------------------------------------------- /man/draw_plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_plot} 4 | \alias{draw_plot} 5 | \title{Draw a (sub)plot.} 6 | \usage{ 7 | draw_plot( 8 | plot, 9 | x = 0, 10 | y = 0, 11 | width = 1, 12 | height = 1, 13 | scale = 1, 14 | hjust = 0, 15 | vjust = 0, 16 | halign = 0.5, 17 | valign = 0.5 18 | ) 19 | } 20 | \arguments{ 21 | \item{plot}{The plot to place. Can be a ggplot2 plot, an arbitrary grob or gtable, 22 | or a recorded base-R plot, as in \code{\link[=as_grob]{as_grob()}}.} 23 | 24 | \item{x}{The x location of the plot. (Left side if \code{hjust = 0}.)} 25 | 26 | \item{y}{The y location of the plot. (Bottom side if \code{vjust = 0}.)} 27 | 28 | \item{width}{Width of the plot.} 29 | 30 | \item{height}{Height of the plot.} 31 | 32 | \item{scale}{Scales the grob relative to the rectangle defined by \code{x}, \code{y}, \code{width}, \code{height}. A setting 33 | of \code{scale = 1} indicates no scaling.} 34 | 35 | \item{hjust, vjust}{Horizontal and vertical justification relative to x.} 36 | 37 | \item{halign, valign}{Horizontal and vertical justification of the plot inside 38 | the box.} 39 | } 40 | \description{ 41 | Places a plot somewhere onto the drawing canvas. By default, coordinates run from 42 | 0 to 1, and the point (0, 0) is in the lower left corner of the canvas. 43 | } 44 | \examples{ 45 | library(ggplot2) 46 | 47 | # make a plot 48 | p <- ggplot(data.frame(x = 1:3, y = 1:3), aes(x, y)) + 49 | geom_point() 50 | # draw into the top-right corner of a larger plot area 51 | ggdraw() + draw_plot(p, .6, .6, .4, .4) 52 | } 53 | -------------------------------------------------------------------------------- /man/ggsave2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/save.R 3 | \name{ggsave2} 4 | \alias{ggsave2} 5 | \title{Cowplot reimplementation of \code{ggsave()}.} 6 | \usage{ 7 | ggsave2( 8 | filename, 9 | plot = ggplot2::last_plot(), 10 | device = NULL, 11 | path = NULL, 12 | scale = 1, 13 | width = NA, 14 | height = NA, 15 | units = c("in", "cm", "mm"), 16 | dpi = 300, 17 | limitsize = TRUE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{filename}{Filename of the plot.} 23 | 24 | \item{plot}{Plot to save, defaults to last plot displayed.} 25 | 26 | \item{device}{Device to use, automatically extract from file name extension.} 27 | 28 | \item{path}{Path to save plot to (if you just want to set \code{path} and not 29 | \code{filename}).} 30 | 31 | \item{scale}{Scaling factor.} 32 | 33 | \item{width}{Width (defaults to the width of current plotting window).} 34 | 35 | \item{height}{Height (defaults to the height of current plotting window).} 36 | 37 | \item{units}{Units for width and height when either one is explicitly specified (in, cm, or mm).} 38 | 39 | \item{dpi}{DPI to use for raster graphics.} 40 | 41 | \item{limitsize}{When \code{TRUE} (the default), \code{ggsave2()} will not 42 | save images larger than 50x50 inches, to prevent the common error of 43 | specifying dimensions in pixels.} 44 | 45 | \item{...}{Other arguments to be handed to the plot device.} 46 | } 47 | \description{ 48 | This function behaves just like \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}}. The main difference is 49 | that by default it doesn't use the Dingbats font for pdf output. The Dingbats font 50 | causes problems with some pdf readers. 51 | } 52 | -------------------------------------------------------------------------------- /man/draw_grob.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \docType{data} 4 | \name{draw_grob} 5 | \alias{draw_grob} 6 | \alias{GeomDrawGrob} 7 | \title{Draw a grob.} 8 | \usage{ 9 | draw_grob( 10 | grob, 11 | x = 0, 12 | y = 0, 13 | width = 1, 14 | height = 1, 15 | scale = 1, 16 | clip = "inherit", 17 | hjust = 0, 18 | vjust = 0, 19 | halign = 0.5, 20 | valign = 0.5 21 | ) 22 | } 23 | \arguments{ 24 | \item{grob}{The grob to place.} 25 | 26 | \item{x}{The x location of the grob. (Left side if \code{hjust = 0}.)} 27 | 28 | \item{y}{The y location of the grob. (Bottom side if \code{vjust = 0}.)} 29 | 30 | \item{width}{Width of the grob.} 31 | 32 | \item{height}{Height of the grob.} 33 | 34 | \item{scale}{Scales the grob relative to the rectangle defined by \code{x}, \code{y}, \code{width}, \code{height}. A setting 35 | of \code{scale = 1} indicates no scaling.} 36 | 37 | \item{clip}{Set to "on" to clip the grob or "inherit" to not clip. Note that clipping doesn't always work as 38 | expected, due to limitations of the grid graphics system.} 39 | 40 | \item{hjust, vjust}{Horizontal and vertical justification relative to x.} 41 | 42 | \item{halign, valign}{Horizontal and vertical justification of the grob inside 43 | the box.} 44 | } 45 | \description{ 46 | Places an arbitrary grob somewhere onto the drawing canvas. By default, coordinates run from 47 | 0 to 1, and the point (0, 0) is in the lower left corner of the canvas. 48 | } 49 | \examples{ 50 | # A grid grob (here a blue circle) 51 | g <- grid::circleGrob(gp = grid::gpar(fill = "blue")) 52 | # place into the middle of the plotting area, at a scale of 50\% 53 | ggdraw() + draw_grob(g, scale = 0.5) 54 | } 55 | \keyword{datasets} 56 | -------------------------------------------------------------------------------- /man/background_grid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{background_grid} 4 | \alias{background_grid} 5 | \title{Add/modify/remove the background grid in a ggplot2 plot} 6 | \usage{ 7 | background_grid( 8 | major = c("xy", "x", "y", "only_minor", "none"), 9 | minor = c("none", "xy", "x", "y"), 10 | size.major = 0.5, 11 | size.minor = 0.2, 12 | color.major = "grey85", 13 | color.minor = "grey85", 14 | colour.major, 15 | colour.minor 16 | ) 17 | } 18 | \arguments{ 19 | \item{major}{Specifies along which axes you would like to plot major grid lines. Options are "xy", "x", 20 | "y", "none".} 21 | 22 | \item{minor}{Specifies along which axes you would like to plot minor grid lines. Options are "xy", "x", 23 | "y", "none".} 24 | 25 | \item{size.major}{Size of the major grid lines.} 26 | 27 | \item{size.minor}{Size of the minor grid lines.} 28 | 29 | \item{color.major, colour.major}{Color of the major grid lines.} 30 | 31 | \item{color.minor, colour.minor}{Color of the minor grid lines.} 32 | } 33 | \description{ 34 | This function provides a simple way to set the background grid in ggplot2. It 35 | doesn't do anything that can't be done just the same with \code{\link[ggplot2:theme]{ggplot2::theme()}}. However, it simplifies 36 | creation of the most commonly needed variations. 37 | } 38 | \details{ 39 | Note: This function completely overwrites all background grid settings of the current theme. If that 40 | is not what you want, you may be better off using \code{\link[ggplot2:theme]{ggplot2::theme()}} directly. 41 | } 42 | \examples{ 43 | library(ggplot2) 44 | 45 | ggplot(iris, aes(Sepal.Length, Sepal.Width)) + 46 | geom_point() + 47 | theme_half_open() + 48 | background_grid() 49 | } 50 | -------------------------------------------------------------------------------- /man/insert_xaxis_grob.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/axis_canvas.R 3 | \name{insert_xaxis_grob} 4 | \alias{insert_xaxis_grob} 5 | \alias{insert_yaxis_grob} 6 | \title{Insert an axis-like grob on either side of a plot panel in a ggplot2 plot.} 7 | \usage{ 8 | insert_xaxis_grob( 9 | plot, 10 | grob, 11 | height = grid::unit(0.2, "null"), 12 | position = c("top", "bottom"), 13 | clip = "on" 14 | ) 15 | 16 | insert_yaxis_grob( 17 | plot, 18 | grob, 19 | width = grid::unit(0.2, "null"), 20 | position = c("right", "left"), 21 | clip = "on" 22 | ) 23 | } 24 | \arguments{ 25 | \item{plot}{The plot into which the grob will be inserted.} 26 | 27 | \item{grob}{The grob to insert. This will generally have been obtained via \code{\link[=get_panel]{get_panel()}} 28 | from a ggplot2 object, in particular one generated with \code{\link[=axis_canvas]{axis_canvas()}}. If a ggplot2 29 | plot is provided instead of a grob, then \code{\link[=get_panel]{get_panel()}} is called to extract the 30 | panel grob.} 31 | 32 | \item{height}{The height of the grob, in grid units. Used by \code{insert_xaxis_grob()}.} 33 | 34 | \item{position}{The position of the grob. Can be \code{"right"} or \code{"left"} for \code{insert_yaxis_grob()} 35 | and \code{"top"} or \code{"botton"} for \code{insert_xaxis_grob()}.} 36 | 37 | \item{clip}{Set to "off" to turn off clipping of the inserted grob.} 38 | 39 | \item{width}{The width of the grob, in grid units. Used by \code{insert_yaxis_grob()}.} 40 | } 41 | \description{ 42 | The function \code{insert_xaxis_grob()} inserts a grob at the top or bottom of the plot panel in a ggplot2 plot. 43 | } 44 | \details{ 45 | For usage examples, see \code{\link[=axis_canvas]{axis_canvas()}}. 46 | } 47 | -------------------------------------------------------------------------------- /R/stamp.R: -------------------------------------------------------------------------------- 1 | #' Stamp plots with a label, such as good, bad, or ugly. 2 | #' 3 | #' @param p The plot to stamp 4 | #' @param color,colour The color of the stamp 5 | #' @param alpha Transparency level of the stamp 6 | #' @param label The text label used for the stamp 7 | #' @param hjust,vjust Horizontal and vertical adjustment of the label 8 | #' @param size Font size 9 | #' @param family Font family 10 | #' @param fontface Font face 11 | #' @param clip Should figure be clipped (default is "on") 12 | #' @param ... Arguments handed off to `stamp()`. 13 | #' @examples 14 | #' library(ggplot2) 15 | #' 16 | #' p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 17 | #' geom_point(aes(color = factor(Petal.Width))) 18 | #' 19 | #' stamp_bad(p + guides(color = "none")) 20 | #' stamp_ugly(p) 21 | #' @export 22 | stamp <- function(p, label, color = "black", alpha = 1, vjust = 1.1, hjust = 1, 23 | size = 14, family = "", fontface = "bold", clip = "on", colour) 24 | { 25 | if (!missing(colour)) { 26 | color <- colour 27 | } 28 | 29 | ggdraw(p, clip = clip) + 30 | draw_text( 31 | paste0(label, " "), 32 | x = 1, y = 1, vjust = vjust, hjust = hjust, size = size, angle = 0, 33 | color = color, alpha = alpha, family = family, fontface = fontface 34 | ) + 35 | draw_line(c(.9999999999, .9999999999), c(0, 1), size = 0.2*size, color = color, alpha = alpha) 36 | } 37 | 38 | #' @rdname stamp 39 | #' @export 40 | stamp_good <- function(p, ...) stamp(p, "good", "olivedrab4", ...) 41 | 42 | #' @rdname stamp 43 | #' @export 44 | stamp_bad <- function(p, ...) stamp(p, "bad", "#d02138", ...) 45 | 46 | #' @rdname stamp 47 | #' @export 48 | stamp_wrong <- function(p, ...) stamp(p, "wrong", "#8E202C", ...) 49 | 50 | #' @rdname stamp 51 | #' @export 52 | stamp_ugly <- function(p, ...) stamp(p, "ugly", "#DC9515", ...) 53 | -------------------------------------------------------------------------------- /man/get_legend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_legend.R 3 | \name{get_legend} 4 | \alias{get_legend} 5 | \title{Retrieve the legend of a plot} 6 | \usage{ 7 | get_legend(plot, legend = NULL) 8 | } 9 | \arguments{ 10 | \item{plot}{A ggplot or gtable from which to retrieve the legend} 11 | 12 | \item{legend}{The specific legend to return, in case there is more than one. Options 13 | are \code{right}, \code{left}, \code{bottom}, \code{top}, \code{inside}. A value of \code{NULL} returns the 14 | first legend.} 15 | } 16 | \value{ 17 | A gtable object holding just the legend or \code{NULL} if there is no legend. 18 | } 19 | \description{ 20 | This function extracts just the legend from a ggplot 21 | } 22 | \examples{ 23 | library(ggplot2) 24 | p <- ggplot(mpg) + 25 | aes(displ, hwy, color = factor(cyl), shape = factor(year)) + 26 | geom_point() + 27 | guides(shape = guide_legend(position = "bottom")) 28 | p 29 | 30 | # default settings retrieve the first legend 31 | ggdraw(get_legend(p)) 32 | # retrieve the bottom legend 33 | ggdraw(get_legend(p, legend = "bottom")) 34 | # retrieve the right legend 35 | ggdraw(get_legend(p, legend = "right")) 36 | 37 | # example demonstrating plot alignment with legend 38 | p1 <- ggplot(mtcars, aes(mpg, disp)) + geom_line() 39 | plot.mpg <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) + geom_point(size=2.5) 40 | # note that these cannot be aligned vertically due to the legend in the plot.mpg 41 | ggdraw(plot_grid(p1, plot.mpg, ncol=1, align='v')) 42 | 43 | legend <- get_legend(plot.mpg) 44 | plot.mpg <- plot.mpg + theme(legend.position='none') 45 | # now plots are aligned vertically with the legend to the right 46 | ggdraw(plot_grid(plot_grid(p1, plot.mpg, ncol=1, align='v'), 47 | plot_grid(NULL, legend, ncol=1), 48 | rel_widths=c(1, 0.2))) 49 | } 50 | -------------------------------------------------------------------------------- /R/get_legend.R: -------------------------------------------------------------------------------- 1 | #' Retrieve the legend of a plot 2 | #' 3 | #' This function extracts just the legend from a ggplot 4 | #' 5 | #' @param plot A ggplot or gtable from which to retrieve the legend 6 | #' @param legend The specific legend to return, in case there is more than one. Options 7 | #' are `right`, `left`, `bottom`, `top`, `inside`. A value of `NULL` returns the 8 | #' first legend. 9 | #' @return A gtable object holding just the legend or \code{NULL} if there is no legend. 10 | #' @examples 11 | #' library(ggplot2) 12 | #' p <- ggplot(mpg) + 13 | #' aes(displ, hwy, color = factor(cyl), shape = factor(year)) + 14 | #' geom_point() + 15 | #' guides(shape = guide_legend(position = "bottom")) 16 | #' p 17 | #' 18 | #' # default settings retrieve the first legend 19 | #' ggdraw(get_legend(p)) 20 | #' # retrieve the bottom legend 21 | #' ggdraw(get_legend(p, legend = "bottom")) 22 | #' # retrieve the right legend 23 | #' ggdraw(get_legend(p, legend = "right")) 24 | #' 25 | #' # example demonstrating plot alignment with legend 26 | #' p1 <- ggplot(mtcars, aes(mpg, disp)) + geom_line() 27 | #' plot.mpg <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) + geom_point(size=2.5) 28 | #' # note that these cannot be aligned vertically due to the legend in the plot.mpg 29 | #' ggdraw(plot_grid(p1, plot.mpg, ncol=1, align='v')) 30 | #' 31 | #' legend <- get_legend(plot.mpg) 32 | #' plot.mpg <- plot.mpg + theme(legend.position='none') 33 | #' # now plots are aligned vertically with the legend to the right 34 | #' ggdraw(plot_grid(plot_grid(p1, plot.mpg, ncol=1, align='v'), 35 | #' plot_grid(NULL, legend, ncol=1), 36 | #' rel_widths=c(1, 0.2))) 37 | #' @export 38 | get_legend <- function(plot, legend = NULL) { 39 | pattern <- "guide-box" 40 | if (!is.null(legend)) { 41 | pattern <- paste0(pattern, "-", legend) 42 | } 43 | get_plot_component(plot, pattern, return_all = FALSE) 44 | } 45 | -------------------------------------------------------------------------------- /man/draw_text.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_text} 4 | \alias{draw_text} 5 | \title{Draw multiple text-strings in one go.} 6 | \usage{ 7 | draw_text(text, x = 0.5, y = 0.5, size = 14, hjust = 0.5, vjust = 0.5, ...) 8 | } 9 | \arguments{ 10 | \item{text}{A vector of Character (not expressions) specifying the string(s) to be written.} 11 | 12 | \item{x}{Vector of x coordinates.} 13 | 14 | \item{y}{Vector of y coordinates.} 15 | 16 | \item{size}{Font size of the text to be drawn.} 17 | 18 | \item{hjust}{(default = 0.5)} 19 | 20 | \item{vjust}{(default = 0.5)} 21 | 22 | \item{...}{Style parameters, such as \code{colour}, \code{alpha}, \code{angle}, \code{size}, etc.} 23 | } 24 | \description{ 25 | This is a convenience function to plot multiple pieces of text at the same time. It cannot 26 | handle mathematical expressions, though. For those, use \code{draw_label}. 27 | } 28 | \details{ 29 | Note that font sizes are scaled by a factor of 2.85, so sizes agree with those of 30 | the theme. This is different from \code{geom_text} in ggplot2. 31 | 32 | By default, the x and y coordinates specify the center of the text box. Set \code{hjust = 0, vjust = 0} to specify 33 | the lower left corner, and other values of \code{hjust} and \code{vjust} for any other relative location you want to 34 | specify. 35 | 36 | For a full list of ... options, see \code{\link[ggplot2:geom_text]{ggplot2::geom_label()}}. 37 | } 38 | \examples{ 39 | # Draw onto a 1*1 drawing surface 40 | ggdraw() + draw_text("Hello World!", x = 0.5, y = 0.5) 41 | # 42 | # Adorn a plot from the Anscombe data set of "identical" data. 43 | library(ggplot2) 44 | 45 | p <- ggplot(anscombe, aes(x1, y1)) + geom_point() + geom_smooth() 46 | three_strings <- c("Hello World!", "to be or not to be", "over and out") 47 | p + draw_text(three_strings, x = 8:10, y = 5:7, hjust = 0) 48 | } 49 | \seealso{ 50 | \code{\link{draw_label}} 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cowplot logo 2 | 3 | # cowplot – Streamlined plot theme and plot annotations for ggplot2 4 | 5 | 6 | [![R build status](https://github.com/wilkelab/cowplot/workflows/R-CMD-check/badge.svg)](https://github.com/wilkelab/cowplot/actions) 7 | [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/cowplot)](https://CRAN.R-project.org/package=cowplot) 8 | [![CRAN\_Downloads\_Badge](https://cranlogs.r-pkg.org/badges/cowplot)](https://cranlogs.r-pkg.org/downloads/total/last-month/cowplot) 9 | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2533860.svg)](https://doi.org/10.5281/zenodo.2533860) 10 | 11 | 12 | 13 | The cowplot package provides various features that help with creating publication-quality figures, such as a set of themes, functions to align plots and arrange them into complex compound figures, and functions that make it easy to annotate plots and or mix plots with images. The package was originally written for internal use in the Wilke lab, hence the name (Claus O. Wilke's plot package). It has also been used extensively in the book [Fundamentals of Data Visualization.](https://clauswilke.com/dataviz/) 14 | 15 | # Installation 16 | 17 | The cowplot package is available on [CRAN](https://cran.r-project.org/package=cowplot) and can be installed via 18 | 19 | install.packages("cowplot") 20 | 21 | To install the latest development version of the package using the devtools package, enter the following in your R console: 22 | 23 | remotes::install_github("wilkelab/cowplot") 24 | 25 | # Usage 26 | 27 | To get a quick introduction to the main features of this package, read the [introductory vignette.](https://wilkelab.org/cowplot/articles/introduction.html) For a more in-depth discussion, read [all vignettes](https://wilkelab.org/cowplot/articles/index.html) and/or the [reference documentation.](https://wilkelab.org/cowplot/reference/index.html) 28 | 29 | -------------------------------------------------------------------------------- /man/set_null_device.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/set_null_device.R 3 | \name{set_null_device} 4 | \alias{set_null_device} 5 | \title{Sets the null graphics device} 6 | \usage{ 7 | set_null_device(null_device) 8 | } 9 | \arguments{ 10 | \item{null_device}{Either a string that defines the null device ("pdf", "png", "cairo", "agg") 11 | or a function that returns a new graphics device.} 12 | } 13 | \description{ 14 | The function \code{\link[=as_grob]{as_grob()}} needs to open a graphics device to render ggplot objects into 15 | grid graphics objects. Unfortunately, there is no universally reliable graphics device available 16 | in R that always works. Therefore, this function allows you to switch out the null device. 17 | } 18 | \details{ 19 | You need to be aware that some graphics devices cause side effects when used as null devices. 20 | If you use an interactive device as null device, you may see an empty plot window pop up. Similarly, 21 | if you use a graphics device that writes a file, then you may find temporary files associated 22 | with the device. The default null device, \code{pdf(NULL)}, does not cause these side effects. However, it has 23 | has other limitations. For example, on OS X, it cannot use all the fonts that are available on the 24 | system. The ragg device can use all fonts, but it will create temporary files. 25 | } 26 | \examples{ 27 | set_null_device("png") # set the png null device 28 | 29 | # create a jpeg null device 30 | jpeg_null_device <- function(width, height) { 31 | jpeg( 32 | filename = tempfile(pattern = "jpeg_null_plot", fileext = ".jpg"), 33 | width = width, height = height, units = "in", res = 96 34 | ) 35 | dev.control("enable") 36 | } 37 | set_null_device(jpeg_null_device) 38 | } 39 | \seealso{ 40 | Available null devices are: \code{\link[=pdf_null_device]{pdf_null_device()}}, \code{\link[=png_null_device]{png_null_device()}}, 41 | \code{\link[=cairo_null_device]{cairo_null_device()}}, \code{\link[=agg_null_device]{agg_null_device()}} 42 | } 43 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(as_grob,"function") 4 | S3method(as_grob,default) 5 | S3method(as_grob,formula) 6 | S3method(as_grob,gList) 7 | S3method(as_grob,ggplot) 8 | S3method(as_grob,grob) 9 | S3method(as_grob,patchwork) 10 | S3method(as_grob,recordedplot) 11 | S3method(as_grob,trellis) 12 | S3method(as_gtable,default) 13 | S3method(as_gtable,grob) 14 | S3method(as_gtable,gtable) 15 | export(GeomDrawGrob) 16 | export(add_sub) 17 | export(agg_null_device) 18 | export(align_margin) 19 | export(align_plots) 20 | export(as_grob) 21 | export(as_gtable) 22 | export(axis_canvas) 23 | export(background_grid) 24 | export(cairo_null_device) 25 | export(circle_key_glyph) 26 | export(draw_figure_label) 27 | export(draw_grob) 28 | export(draw_image) 29 | export(draw_label) 30 | export(draw_line) 31 | export(draw_plot) 32 | export(draw_plot_label) 33 | export(draw_text) 34 | export(get_legend) 35 | export(get_panel) 36 | export(get_panel_component) 37 | export(get_plot_component) 38 | export(get_subtitle) 39 | export(get_title) 40 | export(get_x_axis) 41 | export(get_y_axis) 42 | export(ggdraw) 43 | export(ggsave2) 44 | export(gtable_remove_grobs) 45 | export(gtable_squash_cols) 46 | export(gtable_squash_rows) 47 | export(insert_xaxis_grob) 48 | export(insert_yaxis_grob) 49 | export(panel_border) 50 | export(pdf_null_device) 51 | export(plot_component_names) 52 | export(plot_components) 53 | export(plot_grid) 54 | export(plot_to_gtable) 55 | export(png_null_device) 56 | export(rectangle_key_glyph) 57 | export(save_plot) 58 | export(set_null_device) 59 | export(stamp) 60 | export(stamp_bad) 61 | export(stamp_good) 62 | export(stamp_ugly) 63 | export(stamp_wrong) 64 | export(theme_cowplot) 65 | export(theme_half_open) 66 | export(theme_map) 67 | export(theme_minimal_grid) 68 | export(theme_minimal_hgrid) 69 | export(theme_minimal_vgrid) 70 | export(theme_nothing) 71 | import(ggplot2) 72 | import(grid) 73 | import(rlang) 74 | importFrom(ggplot2,GeomCustomAnn) 75 | importFrom(ggplot2,ggproto) 76 | importFrom(ggplot2,margin) 77 | importFrom(grid,unit) 78 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: cowplot 2 | Title: Streamlined Plot Theme and Plot Annotations for 'ggplot2' 3 | Version: 1.2.0.9000 4 | Authors@R: 5 | person( 6 | given = "Claus O.", 7 | family = "Wilke", 8 | role = c("aut", "cre"), 9 | email = "wilke@austin.utexas.edu", 10 | comment = c(ORCID = "0000-0002-7470-9261") 11 | ) 12 | Description: 13 | Provides various features that help with creating publication-quality figures 14 | with 'ggplot2', such as a set of themes, functions to align plots and arrange 15 | them into complex compound figures, and functions that make it easy to annotate 16 | plots and or mix plots with images. The package was originally written for 17 | internal use in the Wilke lab, hence the name (Claus O. Wilke's plot package). 18 | It has also been used extensively in the book Fundamentals of Data 19 | Visualization. 20 | URL: https://wilkelab.org/cowplot/ 21 | BugReports: https://github.com/wilkelab/cowplot/issues 22 | Depends: 23 | R (>= 3.5.0) 24 | Imports: 25 | ggplot2 (>= 3.5.2), 26 | grid, 27 | gtable, 28 | grDevices, 29 | methods, 30 | rlang, 31 | scales 32 | License: GPL-2 33 | Suggests: 34 | Cairo, 35 | covr, 36 | dplyr, 37 | forcats, 38 | gridGraphics (>= 0.4-0), 39 | knitr, 40 | lattice, 41 | magick, 42 | maps, 43 | PASWR, 44 | patchwork, 45 | rmarkdown, 46 | ragg, 47 | testthat (>= 1.0.0), 48 | tidyr, 49 | vdiffr (>= 0.3.0), 50 | VennDiagram 51 | VignetteBuilder: knitr 52 | Collate: 53 | 'add_sub.R' 54 | 'align_plots.R' 55 | 'as_grob.R' 56 | 'as_gtable.R' 57 | 'axis_canvas.R' 58 | 'cowplot.R' 59 | 'draw.R' 60 | 'get_plot_component.R' 61 | 'get_axes.R' 62 | 'get_titles.R' 63 | 'get_legend.R' 64 | 'get_panel.R' 65 | 'gtable.R' 66 | 'key_glyph.R' 67 | 'plot_grid.R' 68 | 'save.R' 69 | 'set_null_device.R' 70 | 'setup.R' 71 | 'stamp.R' 72 | 'themes.R' 73 | 'utils_ggplot2.R' 74 | RoxygenNote: 7.3.2 75 | Roxygen: list(markdown = TRUE) 76 | Encoding: UTF-8 77 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /R/get_panel.R: -------------------------------------------------------------------------------- 1 | #' Retrieve the panel or part of a panel of a plot 2 | #' 3 | #' `get_panel()` extracts just the main panel from a ggplot or a specified panel 4 | #' in a faceted plot. `get_panel_component()` extracts components from the 5 | #' panel, such as geoms. 6 | #' 7 | #' @param plot A ggplot or gtable from which to retrieve the panel 8 | #' @param panel An integer indicating which panel to pull. ggplot orders panels 9 | #' column-wise, so this is in order from the top left down. 10 | #' @param return_all If there is more than one panel, should all be returned 11 | #' as a list? Default is `FALSE`. 12 | #' @param pattern the name of the component 13 | #' @return A gtable object holding the panel(s) or a grob of the component 14 | #' @examples 15 | #' library(ggplot2) 16 | #' 17 | #' p <- ggplot(mpg, aes(displ, cty)) + geom_point() 18 | #' plot_panel <- get_panel(p) 19 | #' ggdraw(plot_panel) 20 | #' 21 | #' ggdraw(get_panel_component(plot_panel, "geom_point")) 22 | #' 23 | #' @export 24 | get_panel <- function(plot, panel = NULL, return_all = FALSE) { 25 | plot <- as_gtable(plot) 26 | panel_locs <- grepl("panel", plot_component_names(plot)) 27 | panels <- plot_components(plot)[panel_locs] 28 | if (length(panels) > 1 && is.null(panel) && !return_all) 29 | warning("Multiple panels found; returning the first one. Select a panel with `panel` or return all with `return_all = TRUE`.") 30 | 31 | if (!is.null(panel)) { 32 | panels <- panels[[panel]] 33 | } else if (!return_all) { 34 | panels <- panels[[1]] 35 | } 36 | 37 | invisible(panels) 38 | } 39 | 40 | #' @rdname get_panel 41 | #' @export 42 | get_panel_component <- function(panel, pattern) { 43 | grobs <- panel$children 44 | grobIndex <- which(grepl(pattern, panel$childrenOrder)) 45 | 46 | if (length(grobIndex) != 0) { 47 | if (length(grobIndex) > 1) { 48 | warning("multiple components found; returning the first one") 49 | grobIndex <- grobIndex[1] 50 | } 51 | 52 | matched_grobs <- grobs[[grobIndex]] 53 | } 54 | else { 55 | matched_grobs <- NULL 56 | } 57 | 58 | invisible(matched_grobs) 59 | } 60 | -------------------------------------------------------------------------------- /man/draw_figure_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_figure_label} 4 | \alias{draw_figure_label} 5 | \title{Add a label to a figure} 6 | \usage{ 7 | draw_figure_label( 8 | label, 9 | position = c("top.left", "top", "top.right", "bottom.left", "bottom", "bottom.right"), 10 | size, 11 | fontface, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{label}{Label to be drawn} 17 | 18 | \item{position}{Position of the label, can be one of "top.left", "top", "top.right", "bottom.left", "bottom", "bottom.right". Default is "top.left"} 19 | 20 | \item{size}{(optional) Size of the label to be drawn. Default is the text size of the current theme} 21 | 22 | \item{fontface}{(optional) Font face of the label to be drawn. Default is the font face of the current theme} 23 | 24 | \item{...}{other arguments passed to \code{draw_plot_label}} 25 | } 26 | \description{ 27 | The main purpose of this function is to add labels specifying extra information about 28 | the figure, such as "Figure 1", or "A" - often useful in cowplots with more than 29 | one pane. The function is similar to \code{draw_plot_label}. 30 | } 31 | \examples{ 32 | library(ggplot2) 33 | df <- data.frame( 34 | x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3, y4 = (1:10)^4 35 | ) 36 | 37 | p1 <- ggplot(df, aes(x, y1)) + geom_point() 38 | p2 <- ggplot(df, aes(x, y2)) + geom_point() 39 | p3 <- ggplot(df, aes(x, y3)) + geom_point() 40 | p4 <- ggplot(df, aes(x, y4)) + geom_point() 41 | 42 | # Create a simple grid 43 | p <- plot_grid(p1, p2, p3, p4, align = 'hv') 44 | 45 | # Default font size and position 46 | p + draw_figure_label(label = "Figure 1") 47 | 48 | # Different position and font size 49 | p + draw_figure_label(label = "Figure 1", position = "bottom.right", size = 10) 50 | 51 | # Using bold font face 52 | p + draw_figure_label(label = "Figure 1", fontface = "bold") 53 | 54 | # Making the label red and slanted 55 | p + draw_figure_label(label = "Figure 1", angle = -45, colour = "red") 56 | 57 | # Labeling an individual plot 58 | ggdraw(p2) + draw_figure_label(label = "Figure 1", position = "bottom.right", size = 10) 59 | 60 | } 61 | \seealso{ 62 | \code{\link{draw_plot_label}} 63 | } 64 | \author{ 65 | Ulrik Stervbo (ulrik.stervbo @ gmail.com) 66 | } 67 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /man/rectangle_key_glyph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/key_glyph.R 3 | \name{rectangle_key_glyph} 4 | \alias{rectangle_key_glyph} 5 | \alias{circle_key_glyph} 6 | \title{Create customizable legend key glyphs} 7 | \usage{ 8 | rectangle_key_glyph( 9 | colour = NA, 10 | fill = fill, 11 | alpha = alpha, 12 | size = size, 13 | linetype = linetype, 14 | padding = unit(c(0, 0, 0, 0), "pt"), 15 | color 16 | ) 17 | 18 | circle_key_glyph( 19 | colour = NA, 20 | fill = fill, 21 | alpha = alpha, 22 | size = size, 23 | linetype = linetype, 24 | padding = unit(c(0, 0, 0, 0), "pt"), 25 | color 26 | ) 27 | } 28 | \arguments{ 29 | \item{colour, color}{Unquoted name of the aesthetic to use for the outline color, 30 | usually \code{colour}, \code{color}, or \code{fill}. Can also be a color constant, e.g. \code{"red"}.} 31 | 32 | \item{fill}{Unquoted name of the aesthetic to use for the fill color, 33 | usually \code{colour}, \code{color}, or \code{fill}. Can also be a color constant, e.g. \code{"red"}.} 34 | 35 | \item{alpha}{Unquoted name of the aesthetic to use for alpha, 36 | usually \code{alpha}. Can also be a numerical constant, e.g. \code{0.5}.} 37 | 38 | \item{size}{Unquoted name of the aesthetic to use for the line thickness of the 39 | outline, usually \code{size}. Can also be a numerical constant, e.g. \code{0.5}.} 40 | 41 | \item{linetype}{Unquoted name of the aesthetic to use for the line type of the 42 | outline, usually \code{linetype}. Can also be a constant, e.g. \code{2}.} 43 | 44 | \item{padding}{Unit vector with four elements specifying the top, right, bottom, 45 | and left padding from the edges of the legend key to the edges of the key glyph.} 46 | } 47 | \description{ 48 | These functions create customizable legend key glyphs, such as filled rectangles or 49 | circles. 50 | } 51 | \examples{ 52 | library(ggplot2) 53 | 54 | set.seed(1233) 55 | df <- data.frame( 56 | x = sample(letters[1:2], 10, TRUE), 57 | y = rnorm(10) 58 | ) 59 | 60 | ggplot(df, aes(x, y, color = x)) + 61 | geom_boxplot( 62 | key_glyph = rectangle_key_glyph(fill = color, padding = margin(3, 3, 3, 3)) 63 | ) 64 | 65 | ggplot(df, aes(x, y, color = x)) + 66 | geom_boxplot( 67 | key_glyph = circle_key_glyph( 68 | fill = color, 69 | color = "black", linetype = 3, size = 0.3, 70 | padding = margin(2, 2, 2, 2) 71 | ) 72 | ) 73 | } 74 | -------------------------------------------------------------------------------- /man/theme_minimal_grid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \name{theme_minimal_grid} 4 | \alias{theme_minimal_grid} 5 | \alias{theme_minimal_vgrid} 6 | \alias{theme_minimal_hgrid} 7 | \title{Minimalistic themes with grids} 8 | \usage{ 9 | theme_minimal_grid( 10 | font_size = 14, 11 | font_family = "", 12 | line_size = 0.5, 13 | rel_small = 12/14, 14 | rel_tiny = 11/14, 15 | rel_large = 16/14, 16 | color = "grey85", 17 | colour 18 | ) 19 | 20 | theme_minimal_vgrid( 21 | font_size = 14, 22 | font_family = "", 23 | line_size = 0.5, 24 | rel_small = 12/14, 25 | rel_tiny = 11/14, 26 | rel_large = 16/14, 27 | color = "grey85", 28 | colour 29 | ) 30 | 31 | theme_minimal_hgrid( 32 | font_size = 14, 33 | font_family = "", 34 | line_size = 0.5, 35 | rel_small = 12/14, 36 | rel_tiny = 11/14, 37 | rel_large = 16/14, 38 | color = "grey85", 39 | colour 40 | ) 41 | } 42 | \arguments{ 43 | \item{font_size}{Overall font size.} 44 | 45 | \item{font_family}{Font family for plot title, axis titles and labels, legend texts, etc.} 46 | 47 | \item{line_size}{Line size for grid lines.} 48 | 49 | \item{rel_small}{Relative size of small text (e.g., axis tick labels)} 50 | 51 | \item{rel_tiny}{Relative size of tiny text (e.g., caption)} 52 | 53 | \item{rel_large}{Relative size of large text (e.g., title)} 54 | 55 | \item{color, colour}{Color of grid lines.} 56 | } 57 | \description{ 58 | Three minimalistic themes that provide either a full grid, 59 | a horizontal grid, or a vertical grid. Similar to \code{\link[ggplot2:ggtheme]{ggplot2::theme_minimal()}}, but with some 60 | stylistic differences. Most importantly, these themes do not draw minor grid lines. 61 | Also, font sizes are coordinated with \code{\link[=theme_half_open]{theme_half_open()}} and with the defaults 62 | in the \code{\link[=save_plot]{save_plot()}} function. 63 | } 64 | \details{ 65 | \code{theme_minimal_grid()} provides a minimal grid theme. \code{theme_minimal_hgrid()} strips down 66 | this theme even further and draws only horizontal lines, and \code{theme_minimal_vgrid()} 67 | does the same for vertical lines. 68 | } 69 | \examples{ 70 | library(ggplot2) 71 | 72 | # theme_minimal_grid() 73 | ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + 74 | geom_point() + theme_minimal_grid() 75 | 76 | # theme_minimal_hgrid() 77 | ggplot(mtcars, aes(x = carb)) + 78 | geom_bar(fill = "lightblue") + 79 | scale_y_continuous(limits = c(0, 11.5), expand = c(0, 0)) + 80 | theme_minimal_hgrid() 81 | 82 | # theme_minimal_vgrid() 83 | ggplot(mtcars, aes(x = carb)) + 84 | geom_bar(fill = "lightblue") + 85 | scale_y_continuous(limits = c(0, 11.5), expand = c(0, 0)) + 86 | coord_flip() + 87 | theme_minimal_vgrid() 88 | } 89 | -------------------------------------------------------------------------------- /man/align_margin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/align_plots.R 3 | \name{align_margin} 4 | \alias{align_margin} 5 | \title{Align multiple plots along a specified margin} 6 | \usage{ 7 | align_margin(sizes, margin_to_align, greedy = TRUE) 8 | } 9 | \arguments{ 10 | \item{sizes}{list of dimensions for each plot being aligned. Each element of list 11 | obtained by a call to \code{grob$heights} or \code{grob$widths} (see example).} 12 | 13 | \item{margin_to_align}{string either "first" or "last" for which part of plot area should be aligned. 14 | If vertically aligning, "first" aligns left margin and "last" aligns right margin. If horizontally aligning 15 | "first" aligns top margin and "last" aligns bottom margin.} 16 | 17 | \item{greedy}{if \code{TRUE}, alignment is always achieved by adjusting the most extreme 18 | margin; if \code{FALSE}, and the number of dimensions for each plot are the same, then 19 | all dimensions are jointly adjusted.} 20 | } 21 | \description{ 22 | The function aligns the dimensions of multiple plots along a specified axis, and is solely a helper function 23 | for \code{\link[=align_plots]{align_plots()}} to reduce redundancy. Each element of the \code{sizes} 24 | list corresponds to the dimensions of a plot being aligned. They should be vectors created from calls to 25 | \code{grob$heights} or \code{grob$widths} depending on whether you are aligning vertically or horizontally. 26 | The list of dimensions is generated automatically by the \code{\link[=align_plots]{align_plots()}} function, but see examples. 27 | If the same number of elements exist for all plots for the specified 28 | margin, the function will align individual elements on the margin. Otherwise, it aligns the plot by adding 29 | white space to plot margins so that all margins have the same dimensions. 30 | } 31 | \examples{ 32 | library(ggplot2) 33 | 34 | # Example for how to utilize, though align_plots() does this internally and automatically 35 | df <- data.frame( 36 | x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3 37 | ) 38 | 39 | p1 <- ggplot(df, aes(x, y1)) + geom_point() 40 | p2 <- ggplot(df, aes(x, y2)) + geom_point() 41 | p3 <- ggplot(df, aes(x, y3)) + geom_point() 42 | plots <- list(p1, p2, p3) 43 | grobs <- lapply(plots, as_grob) 44 | plot_widths <- lapply(grobs, function(x) {x$widths}) 45 | # Aligning the left margins of all plots 46 | aligned_widths <- align_margin(plot_widths, "first") 47 | # Aligning the right margins of all plots as well 48 | aligned_widths <- align_margin(aligned_widths, "last") 49 | # Setting the dimensions of plots to the aligned dimensions 50 | for (i in seq_along(plots)) { 51 | grobs[[i]]$widths <- aligned_widths[[i]] 52 | } 53 | # Draw aligned plots 54 | plot_grid(plotlist = grobs, ncol = 1) 55 | } 56 | \keyword{internal} 57 | -------------------------------------------------------------------------------- /R/get_plot_component.R: -------------------------------------------------------------------------------- 1 | #' Get plot components 2 | #' 3 | #' Extract plot components from a ggplot or gtable. `get_plot_component()` 4 | #' extracts specific grobs or a list of grobs. Note that it omits `zeroGrob`s and 5 | #' returns `NULL` if there is no non-zero grob to return. `plot_component_names()` 6 | #' provides the names of the components in the plot. `plot_components()` returns all 7 | #' components as a list. 8 | #' 9 | #' @param plot A ggplot or gtable to extract from. 10 | #' @param pattern The name of the component. 11 | #' @param return_all If there is more than one component, should all be returned 12 | #' as a list? Default is `NA`, which returns the first component with a warning. 13 | #' `TRUE` returns all components. `FALSE` returns the first without warning. 14 | #' 15 | #' @return A grob or list of grobs (`get_plot_component()`, `plot_components()`) 16 | #' or a character vector (`plot_component_names()`) 17 | #' @examples 18 | #' library(ggplot2) 19 | #' 20 | #' p <- ggplot(mpg, aes(displ, cty)) + geom_point() 21 | #' ggdraw(get_plot_component(p, "ylab-l")) 22 | #' 23 | #' @export 24 | get_plot_component <- function(plot, pattern, return_all = NA) { 25 | plot <- as_gtable(plot) 26 | grob_names <- plot_component_names(plot) 27 | grobs <- plot_components(plot) 28 | 29 | # remove zeroGrob's 30 | not_empty <- !vapply( 31 | grobs, 32 | inherits, what = "zeroGrob", 33 | FUN.VALUE = logical(1) 34 | ) 35 | grobs <- grobs[not_empty] 36 | grob_names <- grob_names[not_empty] 37 | 38 | grobIndex <- which(grepl(pattern, grob_names)) 39 | 40 | if (length(grobIndex) != 0) { 41 | if (length(grobIndex) > 1 && !isTRUE(return_all)) { 42 | # If there's more than one grob, return just the first one 43 | if (is.na(return_all)) { 44 | warning("Multiple components found; returning the first one. To return all, use `return_all = TRUE`.") 45 | } 46 | grobIndex <- grobIndex[1] 47 | matched_grobs <- grobs[[grobIndex]] 48 | } else if (length(grobIndex) > 1 && isTRUE(return_all)) { 49 | # If there's more than one grob, return all as a list 50 | matched_grobs <- grobs[grobIndex] 51 | } else { 52 | matched_grobs <- grobs[[grobIndex]] 53 | } 54 | } 55 | # if there's no grob, return NULL 56 | else { 57 | matched_grobs <- NULL 58 | } 59 | 60 | invisible(matched_grobs) 61 | } 62 | 63 | #' @rdname get_plot_component 64 | #' @export 65 | plot_component_names <- function(plot) { 66 | if (gtable::is.gtable(plot)) { 67 | plot$layout$name 68 | } else { 69 | as_gtable(plot)$layout$name 70 | } 71 | } 72 | 73 | #' @rdname get_plot_component 74 | #' @export 75 | plot_components <- function(plot) { 76 | if (gtable::is.gtable(plot)) { 77 | plot$grobs 78 | } else { 79 | as_gtable(plot)$grobs 80 | } 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | /404.html 3 | /ISSUE_TEMPLATE.html 4 | /articles/aligning_plots.html 5 | /articles/drawing_with_on_plots.html 6 | /articles/index.html 7 | /articles/introduction.html 8 | /articles/mixing_plot_frameworks.html 9 | /articles/plot_grid.html 10 | /articles/shared_legends.html 11 | /articles/themes.html 12 | /authors.html 13 | /index.html 14 | /news/index.html 15 | /reference/add_sub.html 16 | /reference/align_margin.html 17 | /reference/align_plots.html 18 | /reference/as_grob.html 19 | /reference/as_gtable.html 20 | /reference/axis_canvas.html 21 | /reference/background_grid.html 22 | /reference/cowplot-package.html 23 | /reference/draw_figure_label.html 24 | /reference/draw_grob.html 25 | /reference/draw_image.html 26 | /reference/draw_label.html 27 | /reference/draw_line.html 28 | /reference/draw_plot.html 29 | /reference/draw_plot_label.html 30 | /reference/draw_text.html 31 | /reference/get_legend.html 32 | /reference/get_panel.html 33 | /reference/get_plot_component.html 34 | /reference/get_title.html 35 | /reference/get_y_axis.html 36 | /reference/ggdraw.html 37 | /reference/ggsave2.html 38 | /reference/gtable_remove_grobs.html 39 | /reference/gtable_squash_cols.html 40 | /reference/gtable_squash_rows.html 41 | /reference/index.html 42 | /reference/insert_xaxis_grob.html 43 | /reference/panel_border.html 44 | /reference/plot_grid.html 45 | /reference/png_null_device.html 46 | /reference/rectangle_key_glyph.html 47 | /reference/save_plot.html 48 | /reference/set_null_device.html 49 | /reference/stamp.html 50 | /reference/theme_cowplot.html 51 | /reference/theme_map.html 52 | /reference/theme_minimal_grid.html 53 | /reference/theme_nothing.html 54 | 55 | 56 | -------------------------------------------------------------------------------- /man/align_plots.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/align_plots.R 3 | \name{align_plots} 4 | \alias{align_plots} 5 | \title{Align multiple plots vertically and/or horizontally} 6 | \usage{ 7 | align_plots( 8 | ..., 9 | plotlist = NULL, 10 | align = c("none", "h", "v", "hv"), 11 | axis = c("none", "l", "r", "t", "b", "lr", "tb", "tblr"), 12 | greedy = TRUE 13 | ) 14 | } 15 | \arguments{ 16 | \item{...}{List of plots to be aligned.} 17 | 18 | \item{plotlist}{(optional) List of plots to display. Alternatively, the plots can be provided 19 | individually as the first n arguments of the function align_plots (see plot_grid examples).} 20 | 21 | \item{align}{(optional) Specifies whether graphs in the grid should be horizontally ("h") or 22 | vertically ("v") aligned. Options are \code{align="none"} (default), "hv" (align in both directions), "h", and "v".} 23 | 24 | \item{axis}{(optional) Specifies whether graphs should be aligned by the left ("l"), right ("r"), top ("t"), or bottom ("b") 25 | margins. Options are \code{axis="none"} (default), or a string of any combination of "l", "r", "t", and/or "b" in any order 26 | (e.g. \code{axis="tblr"} or \code{axis="rlbt"} for aligning all margins)} 27 | 28 | \item{greedy}{(optional) Defines the alignment policy when alignment axes are specified via the 29 | \code{axis} option. \code{greedy = TRUE} tries to always align by adjusting the outmost margin. \code{greedy = FALSE} 30 | aligns all columns/rows in the gtable if possible.} 31 | } 32 | \description{ 33 | Align the plot area of multiple plots. Inputs are a list of plots plus alignment parameters. 34 | Horizontal or vertical alignment or both are possible. In the simplest case the function will align all 35 | elements of each plot, but it can handle more complex cases as long as the axis parameter is defined. In this case, 36 | alignment is done through a call to \code{\link[=align_margin]{align_margin()}}. The function \code{align_plots} is called by the \code{\link[=plot_grid]{plot_grid()}} function 37 | and is usually not called directly, though direct calling of the function is useful if plots with 38 | multiple y-axes are desired (see example). 39 | } 40 | \examples{ 41 | library(ggplot2) 42 | 43 | p1 <- ggplot(mpg, aes(manufacturer, hwy)) + stat_summary(fun.y="median", geom = "bar") + 44 | theme_half_open() + 45 | theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust= 1)) 46 | p2 <- ggplot(mpg, aes(manufacturer, displ)) + geom_point(color="red") + 47 | scale_y_continuous(position = "right") + 48 | theme_half_open() + theme(axis.text.x = element_blank()) 49 | 50 | # manually align and plot on top of each other 51 | aligned_plots <- align_plots(p1, p2, align="hv", axis="tblr") 52 | 53 | # Note: In most cases two y-axes should not be used, but this example 54 | # illustrates how one could accomplish it. 55 | ggdraw(aligned_plots[[1]]) + draw_plot(aligned_plots[[2]]) 56 | } 57 | -------------------------------------------------------------------------------- /man/draw_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_label} 4 | \alias{draw_label} 5 | \title{Draw a text label or mathematical expression.} 6 | \usage{ 7 | draw_label( 8 | label, 9 | x = 0.5, 10 | y = 0.5, 11 | hjust = 0.5, 12 | vjust = 0.5, 13 | fontfamily = "", 14 | fontface = "plain", 15 | color = "black", 16 | size = 14, 17 | angle = 0, 18 | lineheight = 0.9, 19 | alpha = 1, 20 | colour 21 | ) 22 | } 23 | \arguments{ 24 | \item{label}{String or plotmath expression to be drawn.} 25 | 26 | \item{x}{The x location (origin) of the label.} 27 | 28 | \item{y}{The y location (origin) of the label.} 29 | 30 | \item{hjust}{Horizontal justification. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.} 31 | 32 | \item{vjust}{Vertical justification. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.} 33 | 34 | \item{fontfamily}{The font family} 35 | 36 | \item{fontface}{The font face ("plain", "bold", etc.)} 37 | 38 | \item{color, colour}{Text color} 39 | 40 | \item{size}{Point size of text} 41 | 42 | \item{angle}{Angle at which text is drawn} 43 | 44 | \item{lineheight}{Line height of text} 45 | 46 | \item{alpha}{The alpha value of the text} 47 | } 48 | \description{ 49 | This function can draw either a character string or mathematical expression at the given 50 | coordinates. It works both on top of \code{ggdraw} and directly with \code{ggplot}, depending 51 | on which coordinate system is desired (see examples). 52 | } 53 | \details{ 54 | By default, the x and y coordinates specify the center of the text box. Set \code{hjust = 0, vjust = 0} to specify 55 | the lower left corner, and other values of \code{hjust} and \code{vjust} for any other relative location you want to 56 | specify. 57 | } 58 | \examples{ 59 | library(ggplot2) 60 | 61 | # setup plot and a label (regression description) 62 | p <- ggplot(mtcars, aes(disp, mpg)) + 63 | geom_line(color = "blue") + 64 | theme_half_open() + 65 | background_grid(minor = 'none') 66 | out <- cor.test(mtcars$disp, mtcars$mpg, method = 'sp', exact = FALSE) 67 | label <- substitute( 68 | paste("Spearman ", rho, " = ", estimate, ", P = ", pvalue), 69 | list(estimate = signif(out$estimate, 2), pvalue = signif(out$p.value, 2)) 70 | ) 71 | 72 | # Add label to plot, centered on {x,y} (in data coordinates) 73 | p + draw_label(label, x = 300, y = 32) 74 | # Add label to plot in data coordinates, flush-left at x, baseline at y. 75 | p + draw_label(label, x = 100, y = 30, hjust = 0, vjust = 0) 76 | 77 | # Add labels via ggdraw. Uses ggdraw coordinates. 78 | # ggdraw coordinates default to xlim = c(0, 1), ylim = c(0, 1). 79 | ggdraw(p) + 80 | draw_label("centered on 70\% of x range,\n90\% of y range", x = 0.7, y = 0.9) 81 | 82 | ggdraw(p) + 83 | draw_label("bottom left at (0, 0)", x = 0, y = 0, hjust = 0, vjust = 0) + 84 | draw_label("top right at (1, 1)", x = 1, y = 1, hjust = 1, vjust = 1) + 85 | draw_label("centered on (0.5, 0.5)", x = 0.5, y = 0.5, hjust = 0.5, vjust = 0.5) 86 | } 87 | \seealso{ 88 | \code{\link{ggdraw}} 89 | } 90 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/key_glyph/rectangle-key-glyph-color-used-as-fill.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | x 41 | 42 | 43 | a 44 | b 45 | rectangle key glyph, color used as fill 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/testthat/test_draw_.R: -------------------------------------------------------------------------------- 1 | context("draw_* functions") 2 | 3 | test_that("draw_grob() can align grobs", { 4 | p <- ggplot() + xlim(0, 1) + ylim(0, 1) 5 | 6 | g <- grid::rectGrob(gp = grid::gpar(fill = "blue")) 7 | 8 | expect_doppelganger("Centered, full width/height", 9 | p + draw_grob(g) 10 | ) 11 | 12 | expect_doppelganger("Centered, half width/height", 13 | p + draw_grob(g, x = .5, y = .5, width = .5, height = .5, hjust = .5, vjust = .5) 14 | ) 15 | 16 | expect_doppelganger("Top left, half width/height", 17 | p + draw_grob(g, x = 0, y = 1, width = .5, height = .5, hjust = 0, vjust = 1) 18 | ) 19 | 20 | expect_doppelganger("Bottom right, half width/height", 21 | p + draw_grob(g, x = 1, y = 0, width = .5, height = .5, hjust = 1, vjust = 0) 22 | ) 23 | }) 24 | 25 | test_that("image placement and scaling", { 26 | img_src <- system.file("extdata", "logo.png", package = "cowplot") 27 | 28 | p <- ggplot() + xlim(0, 1) + ylim(0, 1) 29 | 30 | expect_doppelganger( 31 | "four corners, centered, scaled", 32 | p + 33 | draw_image( 34 | img_src, scale = 0.5, 35 | x = 0, y = 0, width = .4, height = .4, hjust = 0, vjust = 0 36 | ) + 37 | draw_image( 38 | img_src, scale = 0.75, 39 | x = 1, y = 0, width = .4, height = .4, hjust = 1, vjust = 0 40 | ) + 41 | draw_image( 42 | img_src, scale = 1.0, 43 | x = 1, y = 1, width = .4, height = .4, hjust = 1, vjust = 1 44 | ) + 45 | draw_image( 46 | img_src, scale = 1.25, 47 | x = 0, y = 1, width = .4, height = .4, hjust = 0, vjust = 1 48 | ) 49 | ) 50 | 51 | expect_doppelganger( 52 | "four corners, aligned, scaled", 53 | p + 54 | draw_image( 55 | img_src, scale = 0.5, 56 | x = 0, y = 0, width = .4, height = .4, hjust = 0, vjust = 0, 57 | halign = 0, valign = 0 58 | ) + 59 | draw_image( 60 | img_src, scale = 0.75, 61 | x = 1, y = 0, width = .4, height = .4, hjust = 1, vjust = 0, 62 | halign = 1, valign = 0 63 | ) + 64 | draw_image( 65 | img_src, scale = 1.0, 66 | x = 1, y = 1, width = .4, height = .4, hjust = 1, vjust = 1, 67 | halign = 1, valign = 1 68 | ) + 69 | draw_image( 70 | img_src, scale = 1.25, 71 | x = 0, y = 1, width = .4, height = .4, hjust = 0, vjust = 1, 72 | halign = 0, valign = 1 73 | ) 74 | ) 75 | }) 76 | 77 | 78 | 79 | test_that("draw_plot_label() works", { 80 | theme_old <- theme_set( 81 | theme_cowplot() + 82 | theme(text = element_text(color = "red")) 83 | ) 84 | 85 | expect_doppelganger("Label color taken from theme", 86 | ggdraw() + 87 | draw_plot_label(label = "red label", x = .5, y = .5, hjust = .5, vjust = .5) + 88 | theme_map() 89 | ) 90 | expect_doppelganger("Label color specified w/ US spelling", 91 | ggdraw() + 92 | draw_plot_label(label = "blue label", color = "blue", x = .5, y = .5, hjust = .5, vjust = .5) + 93 | theme_map() 94 | ) 95 | expect_doppelganger("Label color specified w/ UK spelling", 96 | ggdraw() + 97 | draw_plot_label(label = "blue label", colour = "blue", x = .5, y = .5, hjust = .5, vjust = .5) + 98 | theme_map() 99 | ) 100 | 101 | theme_set(theme_old) 102 | } 103 | ) 104 | 105 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/key_glyph/circle-key-glyph-color-used-as-fill.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | x 41 | 42 | 43 | a 44 | b 45 | circle key glyph, color used as fill 46 | 47 | 48 | -------------------------------------------------------------------------------- /man/draw_image.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw.R 3 | \name{draw_image} 4 | \alias{draw_image} 5 | \title{Draw an image} 6 | \usage{ 7 | draw_image( 8 | image, 9 | x = 0, 10 | y = 0, 11 | width = 1, 12 | height = 1, 13 | scale = 1, 14 | clip = "inherit", 15 | interpolate = TRUE, 16 | hjust = 0, 17 | vjust = 0, 18 | halign = 0.5, 19 | valign = 0.5 20 | ) 21 | } 22 | \arguments{ 23 | \item{image}{The image to place. Can be a file path, a URL, or a raw vector with image data, 24 | as in \code{magick::image_read()}. Can also be an image previously created by \code{magick::image_read()} and 25 | related functions.} 26 | 27 | \item{x}{The x location of the image. (Left side if \code{hjust = 0}.)} 28 | 29 | \item{y}{The y location of the image. (Bottom side if \code{vjust = 0}.)} 30 | 31 | \item{width}{Width of the image.} 32 | 33 | \item{height}{Height of the image.} 34 | 35 | \item{scale}{Scales the image relative to the rectangle defined by \code{x}, \code{y}, \code{width}, \code{height}. A setting 36 | of \code{scale = 1} indicates no scaling.} 37 | 38 | \item{clip}{Set to "on" to clip the image relative to the box into which it is draw (useful for \code{scale > 1}). 39 | Note that clipping doesn't always work as expected, due to limitations of the grid graphics system.} 40 | 41 | \item{interpolate}{A logical value indicating whether to linearly interpolate the image 42 | (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result).} 43 | 44 | \item{hjust, vjust}{Horizontal and vertical justification relative to x.} 45 | 46 | \item{halign, valign}{Horizontal and vertical justification of the image inside 47 | the box.} 48 | } 49 | \description{ 50 | Places an image somewhere onto the drawing canvas. By default, coordinates run from 51 | 0 to 1, and the point (0, 0) is in the lower left corner of the canvas. Requires the \code{magick} 52 | package to work, and fails gracefully if that package is not installed. 53 | } 54 | \examples{ 55 | library(ggplot2) 56 | 57 | # Use image as plot background 58 | p <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) + 59 | geom_density(alpha = 0.7) + 60 | scale_y_continuous(expand = expansion(mult = c(0, 0.05))) + 61 | theme_half_open(12) 62 | 63 | logo_file <- system.file("extdata", "logo.png", package = "cowplot") 64 | ggdraw() + 65 | draw_image( 66 | logo_file, scale = .7 67 | ) + 68 | draw_plot(p) 69 | 70 | # Place in lower right corner 71 | ggdraw() + 72 | draw_image( 73 | logo_file, scale = .3, x = 1, 74 | hjust = 1, halign = 1, valign = 0 75 | ) + 76 | draw_plot(p) 77 | 78 | \dontrun{ 79 | 80 | # Make grid with plot and image 81 | cow_file <- system.file("extdata", "cow.jpg", package = "cowplot") 82 | p2 <- ggdraw() + draw_image(cow_file, scale = 0.9) 83 | plot_grid( 84 | p + theme(legend.position = c(1, 1), legend.justification = c(1, 1)), 85 | p2, 86 | labels = "AUTO" 87 | ) 88 | 89 | # Manipulate images and draw in plot coordinates 90 | if (requireNamespace("magick", quietly = TRUE)){ 91 | img <- magick::image_transparent( 92 | magick::image_read(logo_file), 93 | color = "white" 94 | ) 95 | img2 <- magick::image_negate(img) 96 | ggplot(data.frame(x = 1:3, y = 1:3), aes(x, y)) + 97 | geom_point(size = 3) + 98 | geom_abline(slope = 1, intercept = 0, linetype = 2, color = "blue") + 99 | draw_image(img , x = 1, y = 1, scale = .9) + 100 | draw_image(img2, x = 2, y = 2, scale = .9) 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot_grid/colwise-arranging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | colwise arranging 82 | 83 | 84 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot_grid/setting-heights-1-1-2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | setting heights, 1:1:2 82 | 83 | 84 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot_grid/setting-widths-1-1-2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | setting widths, 1:1:2 82 | 83 | 84 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot_grid/basic-plot-arranging-with-missing-plot.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | basic plot arranging, with missing plot 82 | 83 | 84 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $("div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Platform 2 | 3 | |field |value | 4 | |:--------|:-------------------------------------| 5 | |version |R version 4.4.2 (2024-10-31) | 6 | |os |macOS Sequoia 15.0.1 | 7 | |system |aarch64, darwin20 | 8 | |ui |RStudio | 9 | |language |(EN) | 10 | |collate |en_US.UTF-8 | 11 | |ctype |en_US.UTF-8 | 12 | |tz |America/Chicago | 13 | |date |2025-06-13 | 14 | |rstudio |2024.12.0+467 Kousa Dogwood (desktop) | 15 | |pandoc |NA | 16 | |quarto |1.6.39 @ /usr/local/bin/quarto | 17 | 18 | # Dependencies 19 | 20 | |package |old |new |Δ | 21 | |:-------|:-----|:------|:--| 22 | |cowplot |1.1.3 |1.2.0 |* | 23 | |cli |NA |3.6.5 |* | 24 | |pillar |NA |1.10.2 |* | 25 | |R6 |NA |2.6.1 |* | 26 | |rlang |NA |1.1.6 |* | 27 | |tibble |NA |3.3.0 |* | 28 | |utf8 |NA |1.2.6 |* | 29 | 30 | # Revdeps 31 | 32 | ## Failed to check (31) 33 | 34 | |package |version |error |warning |note | 35 | |:-------------------------|:-------|:---------|:-------|:----| 36 | |AneuFinder |? | | | | 37 | |Banksy |1.2.0 |1 | |2 | 38 | |bartMan |0.1.1 |1 | | | 39 | |BASiCS |2.18.0 |1 |1 |2 | 40 | |benchdamic |1.12.2 |1 | |3 | 41 | |betaHMM |1.2.1 |1 | | | 42 | |BloodCancerMultiOmics2017 |1.26.0 |1 |1 |3 | 43 | |clustTMB |0.1.0 |1 | | | 44 | |cola |? | | | | 45 | |COTAN |2.6.3 |1 | |3 | 46 | |fgsea |? | | | | 47 | |FLAMES |2.0.2 |1 | |4 | 48 | |GenomicPlot |1.4.0 |1 | |2 | 49 | |GeoMxWorkflows |1.12.0 |1 | |3 | 50 | |graper |1.22.0 |1 | | | 51 | |HiLDA |1.20.0 |1 | | | 52 | |LipinskiFilters |1.0.1 |1 | | | 53 | |MAPFX |1.2.0 |1 | | | 54 | |methodical |1.2.0 |1 |1 |5 | 55 | |miloR |2.2.0 |1 | |3 | 56 | |RCAS |1.32.0 |1 | | | 57 | |rliger |? | | | | 58 | |scGPS |? | | | | 59 | |seqpac |1.6.0 |1 | |1 | 60 | |[spatialLIBD](failures.md#spatiallibd)|1.18.0 |-1 __+1__ | |1 | 61 | |SpatialOmicsOverlay |1.6.0 |1 | | | 62 | |TestAnaAPP |1.1.2 |1 | | | 63 | |text |1.5 |1 | | | 64 | |tidybayes |3.0.7 |1 | | | 65 | |valse |0.1-0 |1 | | | 66 | |variancePartition |1.36.3 |1 |1 |5 | 67 | 68 | ## New problems (4) 69 | 70 | |package |version |error |warning |note | 71 | |:----------|:-------|:-----------|:-------|:----| 72 | |[BeeBDC](problems.md#beebdc)|1.2.1 |1 __+1__ | |1 | 73 | |[IntOMICS](problems.md#intomics)|1.2.0 |__+1__ |1 | | 74 | |[orthos](problems.md#orthos)|1.4.1 |2 -1 __+1__ | |1 | 75 | |[SCIntRuler](problems.md#scintruler)|0.99.6 |__+1__ | | | 76 | 77 | -------------------------------------------------------------------------------- /tests/testthat/test_themes.R: -------------------------------------------------------------------------------- 1 | context("themes") 2 | 3 | test_that("background grids match across themes", { 4 | # background_grid() vs. theme_minimal_grid() grid lines 5 | e1 <- calc_element("panel.grid.major.x", theme_half_open() + background_grid()) 6 | e2 <- calc_element("panel.grid.major.x", theme_minimal_grid()) 7 | e1$inherit.blank <- e2$inherit.blank # these never match 8 | expect_equal(e1, e2) 9 | 10 | e1 <- calc_element("panel.grid.major.y", theme_half_open() + background_grid()) 11 | e2 <- calc_element("panel.grid.major.y", theme_minimal_grid()) 12 | e1$inherit.blank <- e2$inherit.blank # these never match 13 | expect_equal(e1, e2) 14 | 15 | e1 <- calc_element("panel.grid.minor.x", theme_half_open() + background_grid()) 16 | e2 <- calc_element("panel.grid.minor.x", theme_minimal_grid()) 17 | e1$inherit.blank <- e2$inherit.blank # these never match 18 | expect_equal(e1, e2) 19 | 20 | e1 <- calc_element("panel.grid.minor.y", theme_half_open() + background_grid()) 21 | e2 <- calc_element("panel.grid.minor.y", theme_minimal_grid()) 22 | e1$inherit.blank <- e2$inherit.blank # these never match 23 | expect_equal(e1, e2) 24 | 25 | # background_grid() vs. theme_minimal_vgrid() major grid lines 26 | e1 <- calc_element("panel.grid.major.x", theme_half_open() + background_grid(major = "x")) 27 | e2 <- calc_element("panel.grid.major.x", theme_minimal_vgrid()) 28 | e1$inherit.blank <- e2$inherit.blank # these never match 29 | expect_equal(e1, e2) 30 | 31 | e1 <- calc_element("panel.grid.major.y", theme_half_open() + background_grid(major = "x")) 32 | e2 <- calc_element("panel.grid.major.y", theme_minimal_vgrid()) 33 | e1$inherit.blank <- e2$inherit.blank # these never match 34 | expect_equal(e1, e2) 35 | 36 | # background_grid() vs. theme_minimal_hgrid() major grid lines 37 | e1 <- calc_element("panel.grid.major.x", theme_half_open() + background_grid(major = "y")) 38 | e2 <- calc_element("panel.grid.major.x", theme_minimal_hgrid()) 39 | e1$inherit.blank <- e2$inherit.blank # these never match 40 | expect_equal(e1, e2) 41 | 42 | e1 <- calc_element("panel.grid.major.y", theme_half_open() + background_grid(major = "y")) 43 | e2 <- calc_element("panel.grid.major.y", theme_minimal_hgrid()) 44 | e1$inherit.blank <- e2$inherit.blank # these never match 45 | expect_equal(e1, e2) 46 | 47 | }) 48 | 49 | 50 | 51 | # ------------------------------------ 52 | # visual tests 53 | 54 | test_that("themes look right", { 55 | p <- ggplot(mtcars, aes(hp, disp, color = mpg, shape = factor(cyl))) + 56 | geom_point(size = 2) + 57 | guides( 58 | shape = guide_legend(order = 1), 59 | color = guide_colorbar(order = 2) 60 | ) 61 | 62 | expect_doppelganger("theme half open", 63 | p + theme_half_open() 64 | ) 65 | 66 | expect_doppelganger("theme minimal grid", 67 | p + theme_minimal_grid() 68 | ) 69 | 70 | expect_doppelganger("theme minimal hgrid", 71 | p + theme_minimal_hgrid() 72 | ) 73 | 74 | expect_doppelganger("theme minimal vgrid", 75 | p + theme_minimal_vgrid() 76 | ) 77 | 78 | expect_doppelganger("theme half open tiny", 79 | p + theme_half_open(7) 80 | ) 81 | 82 | expect_doppelganger("theme minimal grid tiny", 83 | p + theme_minimal_grid(7) 84 | ) 85 | 86 | expect_doppelganger("theme minimal hgrid tiny", 87 | p + theme_minimal_hgrid(7) 88 | ) 89 | 90 | expect_doppelganger("theme minimal vgrid tiny", 91 | p + theme_minimal_vgrid(7) 92 | ) 93 | 94 | expect_doppelganger("theme half open huge", 95 | p + theme_half_open(22) 96 | ) 97 | 98 | expect_doppelganger("theme minimal grid huge", 99 | p + theme_minimal_grid(22) 100 | ) 101 | 102 | expect_doppelganger("theme minimal hgrid huge", 103 | p + theme_minimal_hgrid(22) 104 | ) 105 | 106 | expect_doppelganger("theme minimal vgrid huge", 107 | p + theme_minimal_vgrid(22) 108 | ) 109 | 110 | }) 111 | -------------------------------------------------------------------------------- /man/axis_canvas.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/axis_canvas.R 3 | \name{axis_canvas} 4 | \alias{axis_canvas} 5 | \title{Generates a canvas onto which one can draw axis-like objects.} 6 | \usage{ 7 | axis_canvas( 8 | plot, 9 | axis = "y", 10 | data = NULL, 11 | mapping = aes(), 12 | xlim = NULL, 13 | ylim = NULL, 14 | coord_flip = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{plot}{The plot defining the x and/or y axis range for the axis canvas.} 19 | 20 | \item{axis}{Specifies which axis to copy from \code{plot}. Can be \code{"x"}, \code{"y"}, or \code{"xy"}.} 21 | 22 | \item{data}{(optional) Data to be displayed in this layer.} 23 | 24 | \item{mapping}{(optional) Aesthetic mapping to be used in this layer.} 25 | 26 | \item{xlim}{(optional) Vector of two numbers specifying the limits of the x axis. Ignored 27 | if the x axis is copied over from \code{plot}.} 28 | 29 | \item{ylim}{(optional) Vector of two numbers specifying the limits of the y axis. Ignored 30 | if the y axis is copied over from \code{plot}.} 31 | 32 | \item{coord_flip}{(optional) If \code{true}, flips the coordinate system and applies x limits to 33 | the y axis and vice versa. Useful in combination with ggplot2's \code{\link[ggplot2:coord_flip]{ggplot2::coord_flip()}} function.} 34 | } 35 | \description{ 36 | This function takes an existing ggplot2 plot and copies one or both of the axis into a new plot. 37 | The main idea is to use this in conjunction with \code{\link[=insert_xaxis_grob]{insert_xaxis_grob()}} or \code{\link[=insert_yaxis_grob]{insert_yaxis_grob()}} to 38 | draw custom axis-like objects or margin annotations. Importantly, while this function works for 39 | both continuous and discrete scales, notice that discrete scales are converted into continuous scales 40 | in the returned axis canvas. The levels of the discrete scale are placed at continuous values of 41 | 1, 2, 3, etc. See Examples for an example of how to convert a discrete scale into a continuous 42 | scale. 43 | } 44 | \examples{ 45 | # annotate line graphs with labels on the right 46 | library(dplyr) 47 | library(tidyr) 48 | library(ggplot2) 49 | theme_set(theme_half_open()) 50 | x <- seq(0, 10, .1) 51 | d <- data.frame(x, 52 | linear = x, 53 | squared = x*x/5, 54 | cubed = x*x*x/25) \%>\% 55 | gather(fun, y, -x) 56 | 57 | pmain <- ggplot(d, aes(x, y, group = fun)) + geom_line() + 58 | scale_x_continuous(expand = c(0, 0)) 59 | 60 | paxis <- axis_canvas(pmain, axis = "y") + 61 | geom_text(data = filter(d, x == max(x)), aes(y = y, label = paste0(" ", fun)), 62 | x = 0, hjust = 0, vjust = 0.5) 63 | ggdraw(insert_yaxis_grob(pmain, paxis, grid::unit(.25, "null"))) 64 | 65 | # discrete scale with integrated color legend 66 | pmain <- ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + 67 | geom_violin(trim = FALSE) + guides(fill = "none") + 68 | scale_x_discrete(labels = NULL) + 69 | theme_minimal() 70 | 71 | label_data <- data.frame(x = 1:nlevels(iris$Species), 72 | Species = levels(iris$Species)) 73 | paxis <- axis_canvas(pmain, axis = "x", data = label_data, mapping = aes(x = x)) + 74 | geom_tile(aes(fill = Species, y = 0.5), width = 0.9, height = 0.3) + 75 | geom_text(aes(label = Species, y = 0.5), hjust = 0.5, vjust = 0.5, size = 11/.pt) 76 | ggdraw(insert_xaxis_grob(pmain, paxis, grid::unit(.07, "null"), 77 | position = "bottom")) 78 | 79 | # add marginal density distributions to plot 80 | pmain <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point() 81 | 82 | xdens <- axis_canvas(pmain, axis = "x") + 83 | geom_density(data=iris, aes(x=Sepal.Length, fill=Species), alpha=0.7, size=.2) 84 | 85 | # need to set `coord_flip = TRUE` if you plan to use `coord_flip()` 86 | ydens <- axis_canvas(pmain, axis = "y", coord_flip = TRUE) + 87 | geom_density(data=iris, aes(x=Sepal.Width, fill=Species), alpha=0.7, size=.2) + 88 | coord_flip() 89 | 90 | p1 <- insert_xaxis_grob(pmain, xdens, grid::unit(.2, "null"), position = "top") 91 | p2 <- insert_yaxis_grob(p1, ydens, grid::unit(.2, "null"), position = "right") 92 | ggdraw(p2) 93 | } 94 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot_grid/scaling-plots.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | A 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | B 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | C 84 | scaling plots 85 | 86 | 87 | -------------------------------------------------------------------------------- /man/save_plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/save.R 3 | \name{save_plot} 4 | \alias{save_plot} 5 | \title{Alternative to \code{ggsave()}, with better support for multi-figure plots.} 6 | \usage{ 7 | save_plot( 8 | filename, 9 | plot, 10 | ncol = 1, 11 | nrow = 1, 12 | base_height = 3.71, 13 | base_asp = 1.618, 14 | base_width = NULL, 15 | ..., 16 | cols, 17 | rows, 18 | base_aspect_ratio, 19 | width, 20 | height 21 | ) 22 | } 23 | \arguments{ 24 | \item{filename}{Name of the plot file to generate.} 25 | 26 | \item{plot}{Plot to save.} 27 | 28 | \item{ncol}{Number of subplot columns.} 29 | 30 | \item{nrow}{Number of subplot rows.} 31 | 32 | \item{base_height}{The height (in inches) of the plot or of one sub-plot if \code{nrow} 33 | or \code{ncol} > 1. Default is 3.71.} 34 | 35 | \item{base_asp}{The aspect ratio (width/height) of the plot or of one sub-plot if \code{nrow} 36 | or \code{ncol} > 1. This argument is used if \code{base_width = NULL} or if \code{base_height = NULL}; 37 | if both width and height are provided then the aspect ratio is ignored. 38 | The default is 1.618 (the golden ratio), which works well for figures with a legend.} 39 | 40 | \item{base_width}{The width (in inches) of the plot or of one sub-plot if \code{nrow} 41 | or \code{ncol} > 1. Default is \code{NULL}, which means that the width is calculated from 42 | \code{base_height} and \code{base_aspect_ratio}.} 43 | 44 | \item{...}{Other arguments to be handed to \code{\link[=ggsave2]{ggsave2()}}.} 45 | 46 | \item{cols}{Deprecated. Use \code{ncol}.} 47 | 48 | \item{rows}{Deprecated. Use \code{nrow}.} 49 | 50 | \item{base_aspect_ratio}{Deprecated. Use \code{base_asp}.} 51 | 52 | \item{width}{Deprecated. Don't use.} 53 | 54 | \item{height}{Deprecated. Don't use.} 55 | } 56 | \description{ 57 | This function replaces the standard \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} function for saving a plot into a file. It 58 | has several advantages over \code{ggsave()}. First, it uses default sizes that work well with 59 | the cowplot theme, so that frequently a plot size does not have to be explicitly specified. Second, it 60 | acknowledges that one often first develops individual plots and then combines them into 61 | multi-plot figures, and it makes it easy---in combination with \code{\link[=plot_grid]{plot_grid()}}---to carry out 62 | this workflow. Finally, it makes it easy to adjust the aspect ratio of the figure, which is 63 | frequently necessary to accommodate plots with or without figure legend. 64 | } 65 | \details{ 66 | The key idea for this function is that plots are often grids, with sup-plots at the individual 67 | grid locations. Therefore, for this function we specify a base width and aspect ratio that apply 68 | to one sup-plot, and we then specify how many rows and columns of subplots we have. This means that 69 | if we have code that can save a single figure, it is trivial to adapt this code to save a combination 70 | of multiple comparable figures. See examples for details. 71 | } 72 | \examples{ 73 | \donttest{ 74 | library(ggplot2) 75 | 76 | # save a single plot with a legend 77 | p1 <- ggplot(mpg, aes(x = cty, y = hwy, color = factor(cyl))) + 78 | geom_point(size = 2) + 79 | theme_half_open() 80 | 81 | file1 <- tempfile("file1", fileext = ".png") 82 | file2 <- tempfile("file2", fileext = ".png") 83 | save_plot(file1, p1) 84 | # same as file1 but determine base_width given base_height 85 | save_plot(file2, p1, base_height = NULL, base_width = 6) 86 | 87 | # save a single plot without legend, adjust aspect ratio 88 | x <- (1:100)/10 89 | p3 <- ggplot(data.frame(x = x, y = x*sin(x)), aes(x, y)) + 90 | geom_line() + 91 | theme_minimal_hgrid() 92 | file3 <- tempfile("file3", fileext = ".pdf") 93 | save_plot(file3, p3, base_asp = 1.1) 94 | 95 | # now combine with a second plot and save 96 | p3b <- ggplot(data.frame(x = x, y = cos(x)+x), aes(x, y)) + 97 | geom_line() + 98 | theme_minimal_hgrid() 99 | p4 <- plot_grid(p3, p3b, labels = "AUTO") 100 | file4 <- tempfile("file4", fileext = ".pdf") 101 | save_plot(file4, p4, ncol = 2, base_asp = 1.1) 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /vignettes/mixing_plot_frameworks.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Mixing different plotting frameworks" 3 | author: "Claus O. Wilke" 4 | date: "`r Sys.Date()`" 5 | vignette: > 6 | %\VignetteIndexEntry{Mixing different plotting frameworks} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | %\usepackage[utf8]{inputenc} 9 | --- 10 | ```{r message = FALSE, echo = FALSE} 11 | knitr::opts_chunk$set( 12 | fig.width = 4, 13 | fig.height = 3 14 | ) 15 | ``` 16 | 17 | All cowplot functions that take plot objects as input (`ggdraw()`, `draw_plot()`, `plot_grid()`) can handle several different types of objects in addition to ggplot2 objects. Most importantly, they can handle plots produced with base R graphics. However, this functionality is only available if you have the package [gridGraphics](https://CRAN.R-project.org/package=gridGraphics) installed. 18 | 19 | As the first example, we draw a base graphics plot with `ggdraw()` and style the background with the ggplot2 themeing mechanism. 20 | 21 | ```{r message = FALSE} 22 | library(ggplot2) 23 | library(cowplot) 24 | 25 | # define a function that emits the desired plot 26 | p1 <- function() { 27 | par( 28 | mar = c(3, 3, 1, 1), 29 | mgp = c(2, 1, 0) 30 | ) 31 | boxplot(mpg ~ cyl, xlab = "cyl", ylab = "mpg", data = mtcars) 32 | } 33 | 34 | ggdraw(p1) + 35 | theme(plot.background = element_rect(fill = "cornsilk")) 36 | ``` 37 | 38 | We can also add a logo to the plot. 39 | ```{r} 40 | logo_file <- system.file("extdata", "logo.png", package = "cowplot") 41 | 42 | ggdraw() + 43 | draw_image( 44 | logo_file, 45 | x = 1, width = 0.1, 46 | hjust = 1, halign = 1, valign = 0 47 | ) + 48 | draw_plot(p1) 49 | ``` 50 | 51 | And we can draw base graphics and ggplot2 graphics side-by-side in a plot grid. 52 | 53 | ```{r fig.width = 6} 54 | p2 <- ggplot(data = mtcars, aes(factor(cyl), mpg)) + geom_boxplot() 55 | plot_grid(p1, p2) 56 | ``` 57 | 58 | Base R plots can be stored in the form of functions that emit the desired plots (demonstrated above), as recorded plots, or using a convenient formula interface. 59 | 60 | To create a recorded plot, we first draw the base plot, then we record it with `recordPlot()`, and then we can draw it with `ggdraw()`. 61 | 62 | ```{r} 63 | # create base R plot 64 | par(mar = c(3, 3, 1, 1), mgp = c(2, 1, 0)) 65 | boxplot(mpg ~ cyl, xlab = "cyl", ylab = "mpg", data = mtcars) 66 | # record previous base R plot and then draw through ggdraw() 67 | p1_recorded <- recordPlot() 68 | ggdraw(p1_recorded) 69 | ``` 70 | 71 | We can store arbitrarily complex plotting code in formulas by enclosing it into curly braces. 72 | 73 | ```{r} 74 | # store base R plot as formula 75 | p1_formula <- ~{ 76 | par( 77 | mar = c(3, 3, 1, 1), 78 | mgp = c(2, 1, 0) 79 | ) 80 | boxplot(mpg ~ cyl, xlab = "cyl", ylab = "mpg", data = mtcars) 81 | } 82 | ggdraw(p1_formula) 83 | ``` 84 | 85 | There is also support for lattice graphics and grid grobs. 86 | 87 | ```{r message = FALSE, fig.width = 8, fig.height = 6} 88 | # base R 89 | p1 <- ~{ 90 | par( 91 | mar = c(3, 3, 1, 1), 92 | mgp = c(2, 1, 0) 93 | ) 94 | boxplot(mpg ~ cyl, xlab = "cyl", ylab = "mpg", data = mtcars) 95 | } 96 | 97 | # ggplot2 98 | p2 <- ggplot(data = mtcars, aes(factor(cyl), mpg)) + geom_boxplot() 99 | 100 | # lattice 101 | library(lattice) 102 | p3 <- bwplot(~mpg | cyl, data = mtcars) 103 | 104 | # elementary grid graphics objects 105 | library(grid) 106 | p4 <- circleGrob(r = 0.3, gp = gpar(fill = "skyblue")) 107 | 108 | # combine all into one plot 109 | plot_grid(p1, p2, p3, p4, rel_heights = c(.6, 1), labels = "auto") 110 | ``` 111 | 112 | Other packages are supported as long as they return grid grobs. 113 | 114 | ```{r message = FALSE, fig.width = 4.5, fig.height = 4.5} 115 | library(VennDiagram) 116 | 117 | p_venn <- draw.pairwise.venn( 118 | 100, 70, 30, 119 | c("First", "Second"), 120 | fill = c("light blue", "pink"), 121 | alpha = c(0.7, 0.7), 122 | ind = FALSE 123 | ) 124 | 125 | # plot venn diagram and add some margin and enclosing box 126 | ggdraw(p_venn) + 127 | theme( 128 | plot.background = element_rect(fill = NA), 129 | plot.margin = margin(12, 12, 12, 12) 130 | ) 131 | ``` 132 | -------------------------------------------------------------------------------- /tests/testthat/test_plot_grid.R: -------------------------------------------------------------------------------- 1 | context("plot_grid") 2 | 3 | # ------------------------------------ 4 | # visual tests 5 | 6 | test_that("basic plot arranging works", { 7 | p1 <- ggplot() + theme(plot.background = element_rect(fill = "red")) 8 | p2 <- ggplot() + theme(plot.background = element_rect(fill = "green")) 9 | p3 <- ggplot() + theme(plot.background = element_rect(fill = "blue")) 10 | 11 | expect_doppelganger("basic plot arranging, with missing plot", 12 | plot_grid(p1, NULL, p2, p3) + theme_map() # add theme_map() for plot title 13 | ) 14 | 15 | expect_doppelganger("basic plot arranging, labeling", 16 | plot_grid(p1, NULL, p2, p3, labels = "AUTO") + theme_map() # add theme_map() for plot title 17 | ) 18 | 19 | expect_doppelganger("setting widths, 1:1:2", 20 | plot_grid(p1, p2, p3, rel_widths = c(1, 1, 2), nrow = 1) + theme_map() # add theme_map() for plot title 21 | ) 22 | 23 | expect_doppelganger("setting heights, 1:1:2", 24 | plot_grid(p1, p2, p3, rel_heights = c(1, 1, 2), ncol = 1) + theme_map() # add theme_map() for plot title 25 | ) 26 | 27 | expect_doppelganger("scaling plots", 28 | plot_grid(p1, p2, p3, labels = "AUTO", scale = c(.9, .7, .5), nrow = 1) + theme_map() # add theme_map() for plot title 29 | ) 30 | 31 | expect_doppelganger("colwise arranging", 32 | plot_grid(p1, NULL, p2, p3, NULL, byrow = FALSE) + theme_map() # add theme_map() for plot title 33 | ) 34 | }) 35 | 36 | 37 | test_that("alignment", { 38 | # basic alignment 39 | df <- data.frame( 40 | short = c("a", "b", "c"), 41 | long = c("aaaaaaaa", "bbbbbbbb", "ccccccccc"), 42 | x = 1:3 43 | ) 44 | 45 | p1 <- ggplot(df, aes(x, short)) + geom_point() 46 | p2 <- ggplot(df, aes(x, long)) + geom_point() 47 | p3 <- p2 + coord_flip() + theme(axis.text.x = element_text(angle = 90)) 48 | 49 | expect_doppelganger("vertical alignment", 50 | plot_grid(p1, p2, ncol = 1, align = "v") + theme_map() 51 | ) 52 | expect_doppelganger("horizontal alignment", 53 | plot_grid(p1, p3, nrow = 1, align = "h") + theme_map() 54 | ) 55 | expect_doppelganger("horizontal & vertical alignment", 56 | plot_grid(p1, NULL, p2, p3, align = "hv") + theme_map() 57 | ) 58 | 59 | # complex alignment 60 | p4 <- p1 + aes(color = short) 61 | p5 <- p1 + facet_wrap(~long) 62 | expect_doppelganger("horizontal alignment, bottom axis", 63 | plot_grid(p4, p5, align = "h", axis = "b") + theme_map() 64 | ) 65 | expect_doppelganger("horizontal alignment, top axis", 66 | plot_grid(p4, p5, align = "h", axis = "t") + theme_map() 67 | ) 68 | expect_doppelganger("vertical alignment, left axis", 69 | plot_grid(p4, p5, ncol = 1, align = "v", axis = "l") + theme_map() 70 | ) 71 | expect_doppelganger("vertical alignment, right axis", 72 | plot_grid(p4, p5, ncol = 1, align = "v", axis = "r") + theme_map() 73 | ) 74 | expect_doppelganger("h/v alignment, right and top axes", 75 | plot_grid( 76 | p4, p5 + theme(strip.text = element_text(size = 80)), 77 | ncol = 1, align = "hv", axis = "rt" 78 | ) + theme_map() 79 | ) 80 | 81 | # aligning facets with unequal widths 82 | df <- data.frame( 83 | type = c("a", "b", "c"), 84 | xstart = c(1, 1, 1), 85 | xend = c(2, 5, 3), 86 | xend2 = c(3, 2, 5) 87 | ) 88 | 89 | p1 <- ggplot(df, aes(x = xstart, xend = xend, y = 0, yend = 1)) + 90 | geom_segment() + 91 | facet_grid(~type, scales = "free_x", space = "free_x") 92 | 93 | p2 <- ggplot(df, aes(x = xstart, xend = xend2, y = 0, yend = 1000)) + 94 | geom_segment() + 95 | facet_grid(~type, scales = "free_x", space = "free_x") 96 | 97 | expect_doppelganger("aligning faceted plots w/ unequal widths", 98 | plot_grid(p1, p2, ncol = 1, align = 'v', axis = "rl") + theme_map() 99 | ) 100 | }) 101 | 102 | 103 | 104 | test_that("labels reorder by byrow", { 105 | # byrow=TRUE 106 | p_list <- lapply(1:3, \(x) ggplot()) 107 | g <- plot_grid(plotlist = p_list, ncol = 2, labels = 1:3, byrow = TRUE) 108 | expect_equal(layer_data(g, 4)$label, 2) 109 | 110 | # byrow=FALSE 111 | p_list <- lapply(1:3, \(x) ggplot()) 112 | g <- plot_grid(plotlist = p_list, ncol = 2, labels = 1:3, byrow = FALSE) 113 | expect_equal(layer_data(g, 4)$label, 3) 114 | }) 115 | --------------------------------------------------------------------------------