How To Annotate a Plot with Circle in R
In this article, we will discuss how to Annotate a Plot with Circle in R Programming Language. We can do by using ggplot2 package
Aesthetic mappings can be created to the plot object to determine the relationship between the x and y axis respectively. Additional components can be added to the created ggplot object.
ggplot(data = NULL, mapping = aes())
- data – Default dataset to use for plot.
- mapping – List of aesthetic mappings to use for plot.
Geoms can be added to the plot to compute various graphical representations of the data in the plot (points, lines, bars). The geoms may also be specified with the additional mappings, like color to differently color the points pertaining to different groups.
geom_point(aes(color = ))
Annotating a plot with a circle is used to highlight a specific portion of the plot in R. A circle at a specific location and radius can be added to the existing scatter plot in R.
The geom_circle() method in ggforce package annotates the plot with the circle at the given location. It takes as input the x and y coordinates as the center and the radius to annotate a circle around the plot.
geom_circle( mapping , inherit.aes )
- mapping – Set of aesthetic mappings for the method
- inherit.aes – Indicator of whether to inherit default mappings
Example: The coord_fixed() method can be added in order to fix the aspect ratio of the plot