I'm generating a figure that has 4 curves (for example), divided into 2 types - Type1 and Type2 (2 curves of each type). I'm drawing Type1 as a solid line while Type2 is dashed. To not overload the figure, I want to add a text somewhere in the figure that explains that the solid lines are Type1 and the dashed lines are Type2, and not to enter this on every legend entry like in the following example:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.legend_handler import HandlerTuple
x = np.arange(1,10)
a_1 = 2 * x
a_2 = 3 * x
b_1 = 5 * x
b_2 = 6 * x
p1, = plt.plot(x, a_1,)
p2, = plt.plot(x, a_2, linestyle='--')
p3, = plt.plot(x, b_1)
p4, = plt.plot(x, b_2, linestyle='--')
plt.legend([(p1, p2), (p3, p4)], ['A Type1/Type2', 'B Type1/Type2'], numpoints=1,handler_map={tuple: HandlerTuple(ndivide=None)}, handlelength=3)
plt.show()
The result is:
What I would like is something like this:
Where I removed the Type1/Type2 from each legend and added it with black color somewhere appropriate in the figure (marked by a red circle).
Can anybody help?