How to draw circles inside each other with ggplot2?



I want to draw two circles inside each other with ggplot2.

So far my effort is:
make a fake data and plot it with geom_line(). If I convert this with coord_polar() then I will not be able to see two different circles the one inside each other



Created on 2021-12-25 by the reprex package (v2.0.1)

# plot the data
ggplot(data) +
  geom_line(aes(x1,y1)) +

enter image description here

I would avoid the geom_circle option and use the coord_polar option if possible.
The reason is that these two circles have some differences in the x-axis, which I would indicate after drawing the circles.

I would like my plot to look like this
enter image description here


The code you have with coord_polar() is correct, just the plot limits need adjusting to see both the circles, e.g.

ggplot(data) +
  geom_line(aes(x1,y1)) +
  geom_line(aes(x1,y2)) +
  coord_polar() + ylim(c(0,NA))

Output plot

The reason for using ylim is that this is the direction getting transformed to the radius by the coord_polar()

Answered By – Miff

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More