Label plot lines in matplotlib

less than 1 minute read

Label plot lines in matplotlib

Use plt.legend() to show the labels.

plt.plot(x_A,y_A,'g--', label="plot A")
plt.plot(x_B,y_B,'r-o', label="plot A")
plt.legend()
plt.show()

Leave a comment