gpt4 book ai didi

python - 椭圆没有显示 - python matplotlib

转载 作者:太空宇宙 更新时间:2023-11-03 14:03:00 26 4
gpt4 key购买 nike

我正在尝试绘制一个椭圆。

ax = plt.subplot(111)
ellipse = Ellipse(mean1L, ellipse_x, ellipse_y, angle=theta)
ax.add_artist(ellipse)
plt.show()

每个论点看起来都很好,但并没有表现出来。我做错了什么?

最佳答案

椭圆超出轴限制。

您宁愿使用 ax.add_artist(ellipse) 而不是

ax.add_patch(ellipse)

能够轻松调整所添加补丁的轴限制。这将允许稍后调用 ax.autoscale_view() 来自动调整轴限制。

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
ax = plt.subplot(111)

ellipse = Ellipse((2,2), 1,1.5 , angle=60)
ax.add_patch(ellipse)

ax.autoscale_view()
plt.show()

enter image description here

关于python - 椭圆没有显示 - python matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49113813/

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