title: Adding a legend entry with two curves on same entry, python matplotlib
body: <p>I would like to have a legend like the one appearing on the plot below: As you can see the legend entry shows the red line and the blue line on the same entry.</p>
  <p>PD: In my case, the red line is always the same curve, a horizontal straight line.</p>
  <p><a href="https://i.stack.imgur.com/1FofW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1FofW.png" alt="Example graph" /></a>
  How can I do this? I have tried with the examples in <a href="https://matplotlib.org/2.0.2/users/legend_guide.html" rel="nofollow noreferrer">this guide</a>, but they do not apply to my case, since I do not find a &quot;handlebox artist&quot; which applies to my case.</p>
  <p><strong>Edit</strong>: I have tried to apply @Mr.T answer, but in my case I am plotting the blue plot as a bar plot in matplotlib, and I get the following error <code>AttributeError: 'BarContainer' object has no attribute '_transform'</code>.</p>
  <p>What I am doing is</p>
  <pre><code>blue_bars = axes[i].bar(bins[:-1], Wi, width = binsize, label = label_W)
  red_line = axes[i].hlines(0, tstart, tstop, color='red', linewidth = 0.8)
  axes[i].legend([red_line, blue_bars], labels = label_W,
              handler_map={blue_bars: HandlerLine2D(numpoints=5)},
              loc='upper right')
  </code></pre>
  <p>Note that I am creating several subplots in the same axes object, within a for loop that iterates over the variable <code>i</code>. This works with no problem.</p>