python - add legend to pyplot, when using single plot call -


i'm used syntax when plotting multiple lines:

plt.plot(freqs,ps,freqs,psf) 

i tried different variations of label=["ps","psf"] in it, using different kind of parentheses, unable obtain correct legend

plt.plot return list of handles lines. can pass legend, along list of labels:

handles=plt.plot([0,1],[5,6],[0,1],[8,7]) plt.legend(handles,["label a","label b"]) 

Comments