1

I'm used to this 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, but I was always unable to obtain a correct legend

1 Answer 1

2

plt.plot will return a list of handles for the lines. You can pass those to legend, along with a list of labels:

handles=plt.plot([0,1],[5,6],[0,1],[8,7])
plt.legend(handles,["label a","label b"])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.