ggannotate is a point-and-click tool to help you put your annotations exactly where you want them to go.
With ggannotate, you interactively annotate ggplots using a Shiny-based RStudio add-in.
This package is still in an 'experimental' phase. Features are still being added, and the user interface has not yet been finalised. Feedback and suggestions are welcome, via GitHub issue or email to mattcowgill at gmail dot com.
Install from GitHub:
remotes::install_github("mattcowgill/ggannotate")
There are three ways to use ggannotate
:
-
Select some ggplot2 code in RStudio, then invoke the
ggannotate
addin via RStudio’s Addins menu. -
Create a ggplot2 object, then call
ggannotate()
, like this:
library(ggplot2)
p <- ggplot(mtcars,
aes(x = wt, y = mpg)) +
geom_point()
ggannotate::ggannotate(p)
- Wrap some code that creates a ggplot2 object in
ggannotate()
, like this:
ggannotate::ggannotate(ggplot(mtcars,
aes(x = wt, y = mpg)) +
geom_point())
Each of these options will launch a Shiny app. Choose what type of annotation you want, click to place it in the right place, and click ‘copy code’ to copy the annotation code to the clipboard. Then paste the copied code in your script and you’re done!
You can adjust the size of the plot in the Shiny app so you can set it to be the same as your intended output. You can keep repeat the process to add multiple annotations (this will get easier in later versions.)