You may use a proxy artist.
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
for example,
from matplotlib.lines import Line2D
l1 = Line2D([], [], linewidth=3, color=r)
l2 = Line2D([], [], linewidth=3, color=g)
l3 = Line2D([], [], linewidth=3, color=b)
legend([l1,
Hi ,
I wish to add a custom legend to a multicolored line drawn using matplotlib
as shown in the figure below
http://www.scipy.org/Cookbook/Matplotlib/MulticoloredLine
I tried exploring the legend but somehow couldn't figure out its usage and
how to adapt it to multicolored line as in the above