I am creating a grid by plotting several curves using one plot
call as:
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
Here is one possible solution: You may use the fact that underscores do not produce legend entries. So setting all but the first label to "_"
suppresses those to appear in the legend.
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
x = np.array([[0,1], [0,1], [0,1]])
y = np.array([[0,0], [1,1], [2,2]])
ax.plot([0,1],[0,2], label='foo', color='b')
lines = ax.plot(x.T, y.T, label='bar', color='k')
plt.setp(lines[1:], label="_")
ax.legend()
plt.show()