The following program executes fine but only one legend is displayed. How can I have all the four legends displayed? kindly see the image attached.

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()

enter image description here

Edit
Report