Since plt.plot can display more than one line at a time, it returns a list of line2D objects, even if you only draw one line (i.e., in your case, a list of length 1). When you take his pen for a legend, you want to use only the first element of this list (the actual line2D object).
There are (at least) two ways to solve this problem:
1) add a comma after normplt when you call plt.plot to save only the first item from the list in normplt
barplt = plt.bar(bins,frq,width,align='center',label='Dgr') normplt, = plt.plot(bins_n,frq_n,'--r', label='Norm')
2) Use only the first item in the list when you call plt.legend ( normplt[0] ):
barplt = plt.bar(bins,frq,width,align='center',label='Dgr') normplt = plt.plot(bins_n,frq_n,'--r', label='Norm') print normplt
tmdavison
source share