Plotting two histograms

I have two lists that I would like to plot as two separate histograms inside the same
plot. However

pylab.hist(h1list,26,facecolor='r')
pylab.hist(h2list,26,alpha=0.3)
pylab.show()

seems to plot the two histograms with different x-y limits on the axis. Also how can
I force the bins to have the same start and end?

Cheers
   Tommy

Tommy Grav wrote:

I have two lists that I would like to plot as two separate histograms inside the same
plot. However

pylab.hist(h1list,26,facecolor='r')
pylab.hist(h2list,26,alpha=0.3)
pylab.show()

seems to plot the two histograms with different x-y limits on the axis. Also how can
I force the bins to have the same start and end?

Cheers
   Tommy

Tommy: Use the 'bins' keyword to pylab.hist (http://matplotlib.sourceforge.net/matplotlib.pylab.html#-hist).

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Thanks. I noticed that on my own and for the first time in my python programming history
used a list comprehension to generate the bins list :slight_smile: The histograms are now displayed
correctly.

Cheers
   Tommy

···

On Apr 6, 2007, at 1:04 PM, Jeff Whitaker wrote:

Tommy Grav wrote:

I have two lists that I would like to plot as two separate histograms inside the same
plot. However

pylab.hist(h1list,26,facecolor='r')
pylab.hist(h2list,26,alpha=0.3)
pylab.show()

seems to plot the two histograms with different x-y limits on the axis. Also how can
I force the bins to have the same start and end?

Cheers
   Tommy

Tommy: Use the 'bins' keyword to pylab.hist (http://matplotlib.sourceforge.net/matplotlib.pylab.html#-hist).