<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto">Using 'auto' to compute the number of bins with 2D data only uses the first column to compute the range.  This causes all other columns to be incorrectly displayed.</p>
<p dir="auto">Calculating histograms using  bins='auto' with numpy gives the correct behavior.<br>
<strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from pylab import *

# four values to examine
x = randn(1000, 4)*0.1 + arange(4)/7

figure()
ax1 = subplot(211)
plt.hist(x, histtype='step')
legend(['1', '2', '3', '4'])
ax2 = subplot(212)
plt.hist(x, bins='auto', histtype='step')
legend(['1', '2', '3', '4'])

# Match axes so it's clear where the problem is
ax2.set_xlim(ax1.get_xlim())
plt.show()

# Check that numpy doesn't have this bug
_, bins_default = np.histogram(x)
_, bins_auto = np.histogram(x, bins='auto')
assert(np.min(bins_default) == np.min(bins_auto))
assert(np.max(bins_default) == np.max(bins_auto))
"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">pylab</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>

<span class="pl-c"># four values to examine</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">randn</span>(<span class="pl-c1">1000</span>, <span class="pl-c1">4</span>)<span class="pl-c1">*</span><span class="pl-c1">0.1</span> <span class="pl-c1">+</span> <span class="pl-en">arange</span>(<span class="pl-c1">4</span>)<span class="pl-c1">/</span><span class="pl-c1">7</span>

<span class="pl-en">figure</span>()
<span class="pl-s1">ax1</span> <span class="pl-c1">=</span> <span class="pl-en">subplot</span>(<span class="pl-c1">211</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>(<span class="pl-s1">x</span>, <span class="pl-s1">histtype</span><span class="pl-c1">=</span><span class="pl-s">'step'</span>)
<span class="pl-en">legend</span>([<span class="pl-s">'1'</span>, <span class="pl-s">'2'</span>, <span class="pl-s">'3'</span>, <span class="pl-s">'4'</span>])
<span class="pl-s1">ax2</span> <span class="pl-c1">=</span> <span class="pl-en">subplot</span>(<span class="pl-c1">212</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>(<span class="pl-s1">x</span>, <span class="pl-s1">bins</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>, <span class="pl-s1">histtype</span><span class="pl-c1">=</span><span class="pl-s">'step'</span>)
<span class="pl-en">legend</span>([<span class="pl-s">'1'</span>, <span class="pl-s">'2'</span>, <span class="pl-s">'3'</span>, <span class="pl-s">'4'</span>])

<span class="pl-c"># Match axes so it's clear where the problem is</span>
<span class="pl-s1">ax2</span>.<span class="pl-en">set_xlim</span>(<span class="pl-s1">ax1</span>.<span class="pl-en">get_xlim</span>())
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()

<span class="pl-c"># Check that numpy doesn't have this bug</span>
<span class="pl-s1">_</span>, <span class="pl-s1">bins_default</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">histogram</span>(<span class="pl-s1">x</span>)
<span class="pl-s1">_</span>, <span class="pl-s1">bins_auto</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">histogram</span>(<span class="pl-s1">x</span>, <span class="pl-s1">bins</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>)
<span class="pl-k">assert</span>(<span class="pl-s1">np</span>.<span class="pl-en">min</span>(<span class="pl-s1">bins_default</span>) <span class="pl-c1">==</span> <span class="pl-s1">np</span>.<span class="pl-en">min</span>(<span class="pl-s1">bins_auto</span>))
<span class="pl-k">assert</span>(<span class="pl-s1">np</span>.<span class="pl-en">max</span>(<span class="pl-s1">bins_default</span>) <span class="pl-c1">==</span> <span class="pl-s1">np</span>.<span class="pl-en">max</span>(<span class="pl-s1">bins_auto</span>))</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
The range of the histogram corresponds to the range of the last column of data for all columns, see second subplot.</p>

<p dir="auto"><strong>Expected outcome</strong><br>
The range of the histogram should correspond to the min/max of all data, as it is in the first subplot of the example code.</p>


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

<ul dir="auto">
<li>Operating System: Ubuntu</li>
<li>Matplotlib Version:  2.0.0</li>
<li>Python Version:      3.5.2</li>
</ul>
<h3 dir="auto">plt.hist range bug</h3>
<p dir="auto">When using plt.hist with multiple input data sets, not supplying a range, and using a string-based binning option ('auto', for example), the range determined will cut off the later datasets and only fully include the first.</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="import numpy as np
import matplotlib.pyplot as plt

data = np.random.normal(0, 1, size=1000)
data2 = np.random.normal(3, 1, size=1000)
data3 = np.random.normal(6, 1, size=1000)

plt.hist([data, data2, data3], bins='auto', histtype='stepfilled', stacked=False)
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-c1">1000</span>)
<span class="pl-s1">data2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-c1">3</span>, <span class="pl-c1">1</span>, <span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-c1">1000</span>)
<span class="pl-s1">data3</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-c1">6</span>, <span class="pl-c1">1</span>, <span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-c1">1000</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>([<span class="pl-s1">data</span>, <span class="pl-s1">data2</span>, <span class="pl-s1">data3</span>], <span class="pl-s1">bins</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>, <span class="pl-s1">histtype</span><span class="pl-c1">=</span><span class="pl-s">'stepfilled'</span>, <span class="pl-s1">stacked</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/5065341/26168360/6b32991e-3aff-11e7-95ea-bb6b95c98c82.png"><img src="https://cloud.githubusercontent.com/assets/5065341/26168360/6b32991e-3aff-11e7-95ea-bb6b95c98c82.png" alt="bad_hist" style="max-width: 100%;"></a></p>

<p dir="auto"><strong>Expected outcome</strong><br>
This is the plot using the bin-edges as determined by np.histogram using the following code:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="_, be = np.histogram([data, data2, data3], bins='auto')
plt.hist([data, data2, data3], bins=be, histtype='stepfilled', stacked=False)"><pre class="notranslate"><span class="pl-s1">_</span>, <span class="pl-s1">be</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">histogram</span>([<span class="pl-s1">data</span>, <span class="pl-s1">data2</span>, <span class="pl-s1">data3</span>], <span class="pl-s1">bins</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>([<span class="pl-s1">data</span>, <span class="pl-s1">data2</span>, <span class="pl-s1">data3</span>], <span class="pl-s1">bins</span><span class="pl-c1">=</span><span class="pl-s1">be</span>, <span class="pl-s1">histtype</span><span class="pl-c1">=</span><span class="pl-s">'stepfilled'</span>, <span class="pl-s1">stacked</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)</pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/5065341/26168446/b42be1e8-3aff-11e7-9b72-5a78a051055a.png"><img src="https://cloud.githubusercontent.com/assets/5065341/26168446/b42be1e8-3aff-11e7-9b72-5a78a051055a.png" alt="good_hist" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating System: OSX 10.10.5</li>
<li>Matplotlib Version: 2.0.1</li>
<li>Python Version: 2.7.13</li>
<li>Jupyter Version (if applicable): 4.0.6</li>
<li>Other Libraries:</li>
</ul>


<p dir="auto">Python installed via Homebrew, all python packages installed via pip.</p>