ggpubr: alternative package to combine plots and tables

This is an alternative to patchwork. Patchwork is easier to use but has fewer functionality.

The ggarrange() function to combine plots on a graph

The plots need to be stored in a variable if you want to combine them on one graph. You use ggarrange() to combine the plots. It has an extensive list of arguments to specify what the result looks like.

Other functions from ggpubr

  • To remove components in a plot you use rremove()
  • To add text (title, caption…) on the graph you use annotate_figure()

Combine tables and plots

You need the grid.arrange() function of the gridExtra package for this. The table needs to be converted into a graphical object via tableGrob().

Check out these websites for more info on ggpubr and gridExtra:

Combine the legends of the plots on a graph

You have to extracts the legends from the plots and then use ggarrange() to combine them.

Using a plot of the basic plotting system in ggpubr

You have to convert the plot into a ggplot using as.ggplot() from ggplotify package.