椭圆不显示 - python matplotlib

问题描述 投票:1回答:1

我想绘制一个椭圆。

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

每个论点似乎都很好,但它没有出现。我究竟做错了什么?

python matplotlib ellipse
1个回答
1
投票

椭圆超出轴限制。

你宁愿使用而不是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

© www.soinside.com 2019 - 2024. All rights reserved.