【发布时间】:2016-11-30 17:59:07
【问题描述】:
我很难理解图例的处理方式。更多,基本例子来自官方matplotlib legend guide
import matplotlib.pyplot as plt
line_up, = plt.plot([1,2,3], label='Line 2')
line_down, = plt.plot([3,2,1], label='Line 1')
plt.legend(handles=[line_up, line_down])
以TypeError: __init__() got multiple values for keyword argument 'handles' 失败。
我做错了什么?有任何想法吗?
我的 matplotlib 版本是 1.3.1。我在 Ubuntu 14.04..
这是完整的回溯(python 脚本中包含上述行)
heiland@note121:bauHS15_iomapsgenpod$ python testleg.py
Traceback (most recent call last):
File "testleg.py", line 4, in <module>
plt.legend(handles=[line_up, line_down])
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 3381, in legend
ret = gca().legend(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 4778, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
TypeError: __init__() got multiple values for keyword argument 'handles'
【问题讨论】:
-
这很奇怪...你能把 full 的追踪发回来吗?
-
当然,我已将其添加到问题正文中。
-
我无法在 1.4.0 上重现此内容。这要么是一个已经修复的错误,要么是你的安装过程中发生了一些非常有趣的事情。
标签: python matplotlib