<p dir="auto"><a href="https://sourceforge.net/tracker/?func=detail&amp;aid=3178834&amp;group_id=80706&amp;atid=560722" rel="nofollow">Original report at SourceForge, opened Fri Feb 11 22:02:28 2011</a></p>
<p dir="auto">One of the annoying things about axes.hist is that with histtype='step' the automatic legend style is an empty box, instead of a line, as I would expect. This behaviour doesn't seem to make sense, because it seems a line would be much more appropriate for this case. Example code to demonstrate this:</p>
<p dir="auto">import matplotlib.pyplot as plt<br>
plt.hist([0,1,1,2,2,2], [0,1,2,3], histtype='step', label="histtype='step'")<br>
plt.legend()<br>
plt.show()</p>
<p dir="auto">With the current uncustomisability of legend styles one can get around this by using proxy Line2D objects in building the legend, but this can be a common operation and becomes messy and annoying.</p>
<p dir="auto">The cause of this is the fact that in axes.py::7799 (current SVN head), in axes.hist, patch objects are always created, even for the line-based step style. I searched the tracker, and couldn't find this mentioned before.</p>
<p dir="auto">Attached is a patch that makes the very simple change of swapping out the call to .fill for .plot (only the function is changed here, not yet the documentation), and it appears to work but I haven't tested exhaustively.</p>
<ul dir="auto">
<li>Is this intended behaviour, that I am just not understanding the requirement for?</li>
<li>This will cause the return signature to possibly include Line2D's, instead of just patches. Will this break anything?</li>
</ul>
<p dir="auto">Thoughts?</p>
<h3 dir="auto">SourceForge History</h3>
<ul dir="auto">
<li>On Fri Feb 11 22:02:28 2011, by ndevenish: File Added: 401440: histtype_plot.patch</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Paste your code here
#
#"><pre class="notranslate"><span class="pl-c"># Paste your code here</span>
<span class="pl-c">#</span>
<span class="pl-c">#</span></pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# If applicable, paste the console output here
#
#"><pre class="notranslate"><code class="notranslate"># If applicable, paste the console output here
#
#
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system:</li>
<li>Matplotlib version:</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>):</li>
<li>Python version:</li>
<li>Jupyter version (if applicable):</li>
<li>Other libraries:</li>
</ul>