Circle in ggplot2

Hi everyone,

I wanted to add a circle to the centre of my ggplot and the parameters I'd like to pass are x0,y0,radius and the color. I wanted a circle with no fill and the circle should simply be on top of another ggplot.

Any help would be appreciated.

Thank you.

There are several good solutions in this Stack Overflow question, from custom functions to ggforce::geom_circle:

If you need help making any of those solutions work for your situation, go ahead and ask! Just remember that it will be easiest for helpers to help you if you provide a reproducible example of the code you are using.

4 Likes

A very simple approach is to use geom_point with a hollow plotting character:

library(ggplot2)

ggplot(data.frame(x = 0, y = 0), aes(x, y)) + 
    geom_point(size = 25, pch = 1)

Size is imprecise, though. If you want to set an exact radius, the options above are better.

2 Likes

Hey this worked perfectly for my requirement, thank you so much!

If your question's been answered, would you mind choosing a solution? (see FAQ below for how) It makes it a bit easier to visually navigate the site and see which questions still need help.

Thanks

Done, thanks for letting me know about this @mara!

1 Like