<div dir="ltr">pyplot.hist(x) where x is a N (rows) x M (cols) array will generate M histograms and plot on a single Axes object.<div><br></div><div>Consider an array that likely has far fewer columns than your image:</div><div><br></div><div><div>import numpy</div><div>from matplotlib import pyplot</div><div><br></div><div>data = numpy.random.normal(size=(37, 4))</div><div>fig, ax = pyplot.subplots()</div><div>ax.hist(data)</div></div><div><br></div><div>Does that make sense?</div><div>-p</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 6, 2016 at 5:36 AM, Poughon Victor <span dir="ltr"><<a href="mailto:Victor.Poughon@cnes.fr" target="_blank">Victor.Poughon@cnes.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi,<br>
<br>
Working with images as 2D numpy arrays, it's very confusing to find that:<br>
<br>
plt.hist(image.flatten())<br>
plt.hist(image)<br>
<br>
produce such different histograms. What I am expecting is the first one, which is the histogram of the image. But if I forget to flatten the array (which I don't need to do if I use numpy.histogram and then plot, adding to the confusion), the plotted histogram
 is strange. The number of bins is different, and so are the frequencies.<br>
<br>
I'm not sure what the point of this message is, but I'd like to share my experience with this. I just spend a good 30 minutes trying to understand why the matplotlib histogram of my image was clearly wrong. The pyplot.hist and axes.hist documentation are not
 so great in explaining what is plotted with 2D input (I'm still not sure what I'm looking at), or at building an expectation that if you are working with an image, plt.hist(image) is NOT what you want.<br>
<br>
To sum up, numpy.histogram and matplotlib's hist() have VERY different behaviors for 2D input arrays. numpy flattens, and matplotlib does... what exactly?<br>
<br>
Any thoughts?<br>
<br>
cheers,<br>
<div><br>
<div style="font-family:Tahoma;font-size:13px">Victor Poughon<br>
</div>
</div>
</div>
</div>

<br>______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
<br></blockquote></div><br></div>