title: how to set bounds for the x-axis in one figure containing multiple matplotlib histograms and create just one column of graphs?
body: <p>I am struggling to set xlim for each histogram and create 1 column of graphs so the x-axis ticks are aligned. Being new pandas, I am unsure of how to apply answer applies: <a href="https://stackoverflow.com/questions/19280336/overlaying-multiple-histograms-using-pandas">Overlaying multiple histograms using pandas</a>.</p>
  
  <pre><code>&gt;import from pandas import DataFrame, read_csv
  &gt;import matplotlib.pyplot as plt
  &gt;import pandas as pd
  
  &gt;df=DataFrame({'score0':[0.047771,0.044174,0.044169,0.042892,0.036862,0.036684,0.036451,0.035530,0.034657,0.033666],
                'score1':[0.061010,0.054999,0.048395,0.048327,0.047784,0.047387,0.045950,0.045707,0.043294,0.042243]})
  
  &gt;print df
       score0    score1
  0  0.047771  0.061010
  1  0.044174  0.054999
  2  0.044169  0.048395
  3  0.042892  0.048327
  4  0.036862  0.047784
  5  0.036684  0.047387
  6  0.036451  0.045950
  7  0.035530  0.045707
  8  0.034657  0.043294
  9  0.033666  0.042243
  
  &gt;df.hist()
  &gt;plt.xlim(-1.0,1.0)
  </code></pre>
  
  <p>The result sets only one of the bounds on the x-axis to be [-1,1].  </p>
  
  <p>I'm very familiar ggplot in R and just trying out pandas/matplotlib in python.  I'm open to suggestions for better plotting ideas. Any help would be greatly appreciated. </p>
  
  <p><img src="https://i.stack.imgur.com/1vvxO.png" alt="enter image description here"></p>
  
  <p>update #1 (@ct-zhu): </p>
  
  <p>I have tried the following, but the xlim edit on the subplot does not seem to translate the bin widths across the new x-axis values. As a result, the graph now has <strong>odd bin widths</strong> and still has <strong>more than one column of graphs</strong>:</p>
  
  <pre><code>for array in df.hist(bins=10):
      for subplot in array:
          subplot.set_xlim((-1,1))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Rzwv0.png" alt="enter image description here"></p>
  
  <p>update #2:</p>
  
  <p>Getting closer with the use of <code>layout</code>, but the width of bins does not equal the interval length divided by bin count. In the example below, I set <code>bins=10</code>. Hence, the width of each bin over the interval from [-1,1] should be <code>2/10=0.20</code>; however, the graph does not have any bins with a width of 0.20.</p>
  
  <pre><code>for array in df.hist(layout=(2,1),bins=10):
      for subplot in array:
          subplot.set_xlim((-1,1))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/O8xDW.png" alt="enter image description here"></p>