International College of Digital Innovation, CMU
October 30, 2024
The patchwork package is the one extension of ggplot2 package.
The goal of patchwork package is to make it ridiculously simple to combine separate ggplots into the same graphic.
How to in install
How to use their package
From mtcars data set
We can use \(+\) to add plots together in the same row (up to three plots).
We can use \(/\) to add plots together in the same column.
We can mix the plots with multiple rows and columns.
We can control by using this command
As plots will always be added to the patchwork on the left-hand side, it is not possible to nest the left-hand side beside the right-hand side with the standard operators shown above.
As plots will always be added to the patchwork on the right-hand side, it is not possible to nest the left-hand side beside the right-hand side with the standard operators shown above.
Often, especially when it comes to theming, you want to modify everything at once. patchwork provides two additional operators that facilitates this. \&
will add the element to all subplots in the patchwork, and *
will add the element to all the subplots in the current nesting level.
Titles, subtitles and captions
One of the most needed things is to add descriptive text to your plot ensemble. To achieve this, you simply add it to your patchwork using plot_annotation()
What is Plotly?
Plotly is an open-source data visualization library for Python and R written in JavaScript, making graphs inherently interactive.
We can be modified tremendously and are easily exported as images, HTML, etc. for seamless integration into a number of applications.
step 1: Created a ggplot object.
step 2: put ggplot object in ggplotly()
function
plotly is not working with the ggplot object from patchwork.
plotly is not working for pdf output.