畫圖時添加圖例
import matplotlib.pyplot as plt
line_up, = plt.plot([1,2,3])
plt.legend(line_up, 'Up')
plt.show()
報錯zip argument #2 must support iteration
應該是legend的參數需要zip形式。
(for label,handle in zip (labels,handles)
所有改寫成下面形式就好了
import matplotlib.pyplot as plt
line_up, = plt.plot([1,2,3])
plt.legend((line_up,), ('Up',))
plt.show()