Circle in ggplot2

ggplot2

#1

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.


#2

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.


#3

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.


#4

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


#5

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


#6

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