UserWarning: Legend does not support——python matplotlib报错

报错:

UserWarning: Legend does not support [ at 0x00000195927E36C8>] instances. A proxy artist may be used instead.

绘图部分代码

l_a = plt.plot(x, y_weight, color='red', linestyle="--", linewidth=2)  # 在当前绘图对象绘图
l_b = plt.plot(x, y_money, color='blue', linestyle="-.", linewidth=3)

plt.legend(handles=[l_a, l_b], labels=['我不知道', '我也不知道'], prop=my_font)

需要更改代码为
添加上逗号!! 添加的逗号用于解码

l_a, = plt.plot(x, y_weight, color='red', linestyle="--", linewidth=2)  # 在当前绘图对象绘图
l_b, = plt.plot(x, y_money, color='blue', linestyle="-.", linewidth=3)

你可能感兴趣的:(数据处理,python,matplotlib,开发语言)