Mixing Plots with the ggpubr Package

The ggplot extension packages in R allow using multiple plots, offering a powerful data visualization approach. These packages facilitate data scientists and analysts to create rich and informative visualizations for their projects. Various ggplot extension packages help combine multiple ggplot plots for effective data analysis. Similar to the patchwork and cowplot packages, there is another package, the ggpubr package.

Let’s explore how to create beautiful data visualizations containing multiple plots using ggpubr.

Getting started with ggpubr

The ggpubr package is a widely used package, particularly among those who use ggplot2 for their plotting needs. The package’s most notable function is ggarrange().

The ggarrange() function allows us to easily arrange multiple plots in a single figure while providing further customization options.

Additionally, ggpubr offers a variety of other functions for adding mean lines and marginal rugsIt is a one-dimensional distribution plot used to support two-dimensional plots for visualizing the spread of data on each axis. to histograms, adding p-values to boxplots and violin plots, and sorting bar plot groups globally.

First, let’s load the ggpubr package using the following code:

Get hands-on with 1400+ tech skills courses.