我试图在子图中放置一个图例,但我无法做到。这是我正在尝试做的一个例子:
def test():
fig = plt.figure()
ax1 = fig.add_subplot(111)
V = 10
X = range (V)
char = 'a'
leg = []
legp = []
for i in range (0,5):
Y = np.random.randn(V)
ap = ax1.plot(X,Y)
legp.append(ap)
char = chr(ord(char)+1)
leg.append(char)
fig.legend(legp,leg)
fig.show()
这产生了空图例。我还收到一堆警告消息:
warnings.warn("Legend 不支持 %s\n改用代理艺术家。\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle) ,)) /usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [] 使用代理艺术家。
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
warnings.warn("Legend 不支持 %s\n改用代理艺术家。\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle) ,))
我想这与这个“代理艺术家”有关,但它指向的链接指向学习这个开始的链接。
对于那些想知道的人,我只想在图例中包含部分绘制的图。
那我该如何实现呢?
编辑:
我在带有 gnome 的 Ubuntu 12.10 上使用 python 2.7.3。