以下程序执行良好,但只显示一个图例。如何显示所有四个图例?请看附图。
import matplotlib.pyplot as plt
dct = {'list_1' : [1,2,4,3,1],'list_2' : [2,4,5,1,2],'list_3' : [1,1,3,4,6],'list_4' : [1,1,2,2,1]}
xs = [0,1,2,3,4]
for i in [1,2,3,4]:
plt.plot(xs,dct['list_%s' %i])
plt.legend(['%s data' %i])
plt.show()