• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Seaborn
  • Matplotlib
  • ggplot2
  • Altair
  • About
    • Privacy Policy
  • Visualizing Activation Functions in Neural Networks
  • Confusion Matrix Calculator
  • Visualizing Dropout Rate in Neural Network
  • Visualizing Loss Functions in Neural Networks
  • Show Search
Hide Search

How To Annotate a Plot with Circle in R

datavizpyr · May 26, 2021 ·

Last updated on June 8, 2021

In this tutorial, we will learn how to annotate a plot with circle to highlight a select portion of a plot made with ggplot2 in R. There are a few options to add a circle on top of a plot with ggplot2. In this example, we will annotate a plot with a circle at a specific location and radius. We will use ggforce’s geom_circle() function to annotate a plot made with ggplot2 with a circle.

Let us load the packages needed. We will use Palmer penguin dataset to make a scatter plot and annotate it with a circle.

library(tidyverse)
library(palmerpenguins)
theme_set(theme_bw(16))

First, let make a scatterplot using ggplot2’s geom_point().

penguins %>%
  ggplot(aes(x=bill_length_mm, 
             y=bill_depth_mm,
             color=species))+
  geom_point()
Scatterplot with ggplot2
Scatterplot with ggplot2

Let us say we want to highlight a portion of the scatter plot at a scpecific coordinate (x,y) with a circle of radius r. We can use geom_circle() function from ggforce to draw a circle on top of the scatterplot at the specific location. ggforce geom_circle() function’s aes() takes in the location of the center of the circle, the x and y coordinate and radius of the circle.

penguins %>%
  ggplot(aes(x = bill_length_mm,
             y = bill_depth_mm,
             color = species))+
  geom_point()+
  geom_circle(aes(x0 = 38.5, y0 = 18, r = 3),
              inherit.aes = FALSE)
ggsave("annotating_plot_with_circle.png")

geom_circle() annotates the plot with the circle at the given location. Note that even though we specified a circle with a radius, the resulting plot has an ellipse.

How to Annotate a Plot with Circle in ggplot2?
How to Annotate a Plot with Circle in ggplot2?

The reason for annotating with ellispe instead of circle is because our x and y axes’ ranges are very different. ggforce’s geom_circle() is

intended for cartesian coordinate systems and will only produce a true circle if ggplot2::coord_fixed() is used.

So, let us add coord_fixed() to fix the aspect ratio of the plot.

penguins %>%
  ggplot(aes(x = bill_length_mm,
             y = bill_depth_mm,
             color = species))+
  geom_point()+
  geom_circle(aes(x0 = 38.5, y0 = 18, r = 3),
              inherit.aes = FALSE)+
  coord_fixed()
ggsave("annotating_plot_with_circle_coord_fixed.png")

Now we have annotated the plot with a circle as we aimed.

ggforce geom_circle(): Annotate with a circle
ggforce geom_circle(): Annotate with a circle

Explore the Complete ggplot2 Guide

35+ tutorials with code: scatterplots, boxplots, themes, annotations, facets, and more—tested and beginner-friendly.

Visit the ggplot2 Hub → No fluff—just code and visuals.

Related posts:

Customizing Labels on Bars in Side by side Stacked BarplotHow To Add Labels to Grouped Barplot with Bars Side-By-Side in R? Customizing Mean mark to boxplot with ggplot2How To Show Mean Value in Boxplots with ggplot2? Scatterplot with marginal multi-histogram with ggExtraHow To Make Scatterplot with Marginal Histograms in R? Annotate Clusters with Ellipse with Labels ggforceHow To Annotate Clusters with Circle/Ellipse by a Variable in R

Filed Under: annotate with a circle, ggforce geom_circle, ggplot2, R Tagged With: ggplot2, R

Primary Sidebar

Python & R Viz Hubs

  • Seaborn Guide & Cookbook
  • ggplot2 Guide & Cookbook
  • Matplotlib Guide & Cookbook
  • Confusion Matrix Calculator
  • Visualizing Activation Functions
  • Visualizing Dropout
  • Visualizing Loss Functions

Buy Me a Coffee

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version