-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Histogram range appears to be calculated incorrectly when using "bins='auto'" with 2D data #8778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It looks to me that the problem may come from this section in for i in xrange(nx):
# this will automatically overwrite bins,
# so that each histogram uses the same bins
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs) If the ¹ : maybe I am wrong, but one could pass any string that is valid for Edit: English... |
passing any string was intentional since we knew the plan was for numpy to
add more kinds of auto-ranges. If it isn't documented, it should be
something along the lines of "passes this value directly to numpy.hist()".
…On Mon, Jun 19, 2017 at 11:15 AM, Adrien F. Vincent < ***@***.***> wrote:
It looks to me that the problem may come from this section
<https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py#L6102>
in axes.hist:
for i in xrange(nx):
# this will automatically overwrite bins,
# so that each histogram uses the same bins
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
If the bins parameter that is initially passed to hist is “auto¹”, then
bins becomes a sequence after the first iteration, and this iteration will
be kept during the following runs. My first idea would be to just add some
supplementary logic (in the loop?) to take care of the case of bins being
a string.
¹ : maybe I am wrong, but one could pass any string that is valid for
numpy.histogram, don't we? Is it deliberate to not mention it in
ax.docstring? Otherwise, it looks like a pretty kind nice but
unfortunately hidden feature ^^.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8778 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-GhOb8cYoyVtegtxfo1tfGy9R1xaks5sFpClgaJpZM4N-WCA>
.
|
Closing as a duplicate of #8636 |
Indeed (and the on-going PR #8638 may fix this). |
Bug report
Bug summary
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.
Calculating histograms using bins='auto' with numpy gives the correct behavior.
Code for reproduction
Actual outcome
The range of the histogram corresponds to the range of the last column of data for all columns, see second subplot.
Expected outcome
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.
Matplotlib version
The text was updated successfully, but these errors were encountered: