Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a circle without fill in matplotlib

I have a question, which is probably a simple solution. I put down python for quite a few months and now I'm trying to create a few visuals, but I'm mind blanking on how to do it.

import matplotlib.pyplot as plt

circle1 = plt.Circle((0, 0), .5, color='r')

fig, ax = plt.subplots()

plt.xlim(-5,5)
plt.xlabel('AU')
plt.ylim(-5,5)
plt.ylabel('AU')

plt.grid(linestyle='-')

ax.set_aspect(1)

ax.add_artist(circle1)

plt.title('Habitable Zone Around the Sun ', fontsize=8)

plt.show()

This code gives me a fixed "sun" at my origin, and I'm trying to create an "earth orbit" at 1AU, as well as create a radial shell for the habitable zone for in inner and outer radius (say .8 AU and 1.2 AU). I'm probably overthinking this and am going to feel stupid after posting this.

like image 966
Reliquo Avatar asked Oct 19 '25 05:10

Reliquo


1 Answers

Circle() takes a boolean fill argument

Do

circle2 = plt.Circle((0, 0), 3, color='k', fill=False)
ax.add_artist(circle2)

and you get

like image 187
Pranav Hosangadi Avatar answered Oct 21 '25 18:10

Pranav Hosangadi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!