椭圆不显示 - Python Matplotlib

3
我正在尝试绘制一个椭圆。
ax = plt.subplot(111)
ellipse = Ellipse(mean1L, ellipse_x, ellipse_y, angle=theta)
ax.add_artist(ellipse)
plt.show()

每个参数看起来都没问题,但是它没有显示出来。我做错了什么?


1
你能提供一个自包含的示例吗?你的代码使用了在其他地方定义的变量。 - Lev Levitsky
请参考以下链接:https://stackoverflow.com/questions/15408447/why-is-my-ellipse-not-appearing - KolaB
1个回答

4
椭圆形超出了轴限制。
您可以使用以下代码替代 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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接