Graph annotation with ggplot
To produce a publication-quality data visualization, we often need to annotate the graph with various texts, symbols, or even shapes. In this recipe, we will learn how we can easily annotate an existing graph.
Getting ready
In this recipe, we will use the disA
and disD
variables from ggplotdata
. Let's call ggplotdata
for this recipe. We also need to call the grid
and gridExtra
libraries for this recipe.
How to do it...
In this recipe, we will execute the following annotation on an existing scatter plot. So, the whole procedure will be as follows:
- Create a scatter plot.
- Add customized text within the plot.
- Highlight a certain region to indicate extreme values.
- Draw a line segment with an arrow within the scatter plot to indicate ...
Get R: Data Analysis and Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.