为什么我的椭圆没有出现?

时间:2013-03-14 11:50:32

标签: python matplotlib

我正在尝试在matplotlib中绘制一个椭圆,但是当我执行此代码时:

from matplotlib.pyplot import *
from matplotlib.patches import Ellipse

fig = Figure()
ax = fig.add_subplot(111)
ax.add_artist(Ellipse(xy=(1, 1), width=2, height=2, facecolor='g', edgecolor='k', alpha=.1))
show()
根本没有任何反应。我没有数字,更不用说椭圆了。

是什么给出了?

非常感谢!

1 个答案:

答案 0 :(得分:2)

figure必须拼写为小写。您想要create a figure并显示它。如果使用大写拼写,则实例化Figure class

from matplotlib import pyplot as plt
from matplotlib.patches import Ellipse

fig = plt.figure()
ax = fig.add_subplot(111)
ax.add_artist(Ellipse(xy=(1, 1), width=2, height=2, facecolor='g', edgecolor='k', alpha=.1))
plt.show()
相关问题