gpt4 book ai didi

python - 如何在matplotlib中画一个没有填充的圆

转载 作者:行者123 更新时间:2023-12-05 02:48:37 27 4
gpt4 key购买 nike

我有一个问题,这可能是一个简单的解决方案。我使用 Python 好几个月了,现在我正在尝试创建一些视觉效果,但我不知道如何去做。

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()

此代码在我的原点处为我提供了一个固定的“太阳”,我正在尝试在 1AU 处创建一个“地球轨道”,并为内外半径的宜居带创建一个径向壳(比如.8 AU 和 1.2 AU)。我可能想多了,发布后我会觉得自己很愚蠢。

最佳答案

Circle() takes a boolean fill argument

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

你得到

关于python - 如何在matplotlib中画一个没有填充的圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64364398/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com