Once your ggplot2 chart is done, you often need to annotate it to provide more information or highlight a specific part. This is done using the annotate() function.

In this first example, we add 2 text elements on the plot. Please note that to add text from a data.frame, you need to use geom_text!


Now, here are 3 examples showing how to add rectangles, segments and arrows to your plot. The code is quite straightforward:




If you need to add ablines, do not use annotate! The geom_hline and geom_vline have been created for that!



Last, you can add a point and a range around it with the “pointrange” geom:


Not what you are looking for ? Make a new search !


Leave a Reply

Notify of