Skip to content
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

[Bug]: Error in Hexbin plot in Matplotlib 3.0 onward #27383

Closed
Zubair-Physicist opened this issue Nov 27, 2023 · 6 comments
Closed

[Bug]: Error in Hexbin plot in Matplotlib 3.0 onward #27383

Zubair-Physicist opened this issue Nov 27, 2023 · 6 comments
Labels
Documentation: examples files in galleries/examples Good first issue Open a pull request against these issues if there are no active ones!
Milestone

Comments

@Zubair-Physicist
Copy link

Bug summary

First, I would like to thank you for creating a wonderful matplotlib for data visualization.

I am writing to inform you about problems in hexbin plot in the Matplotlib 3.0 onward. When I was working on my data analysis, I noticed something was wrong when we plotted the distribution of the bin in the log scale. Moreover, the hexbin plot is correct in the previous version of the matplotlib 2.2.5.

I've attached the files of the same. You can clearly observe that the main error is when we plot the bins in log scale. I hope you will look into the problem and update it accordingly.

hexplot_matplotlib3 10
hexplot_matplotlib2 2 5

Code for reproduction

no code is available

Actual outcome

NA

Expected outcome

NA

Additional information

No response

Operating system

Windows

Matplotlib Version

3.8.2

Matplotlib Backend

No response

Python version

python 3

Jupyter version

No response

Installation

conda

@ksunden
Copy link
Member

ksunden commented Nov 28, 2023

This was actually incorrect prior to version 3.5:

https://matplotlib.org/3.5.3/api/prev_api_changes/api_changes_3.5.0.html#hexbin-with-a-log-norm

We had been adding 1 so every bin had a value, but 0 cannot be displayed on a logarithmically scaled colormap, so now it has no value (and thus are not displayed if zero). We no longer incorrectly add 1.

There was some changes during the early 3.8 series to the boundary conditions of hexbin, but default behavior should be what it used to be as of 3.8.2 (and more consistent with different modes of calling hexbin overall).

@ksunden ksunden closed this as completed Nov 28, 2023
@Zubair-Physicist
Copy link
Author

Zubair-Physicist commented Dec 4, 2023 via email

@tacaswell
Copy link
Member

I agree that the label on the colorbar should be updated.

At some point we went from having to "manually" do the log scale to the color mapping / normalization machinery doing it for us.

@Zubair-Physicist
Copy link
Author

Zubair-Physicist commented Dec 4, 2023 via email

@jklymak jklymak reopened this Dec 4, 2023
@jklymak jklymak added Good first issue Open a pull request against these issues if there are no active ones! Documentation: examples files in galleries/examples labels Dec 4, 2023
Copy link

github-actions bot commented Dec 4, 2023

Good first issue - notes for new contributors

This issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide.

We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR.

If something is unclear, please reach out on any of our communication channels.

@QuLogic
Copy link
Member

QuLogic commented Dec 5, 2023

The relevant change here was #9223, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: examples files in galleries/examples Good first issue Open a pull request against these issues if there are no active ones!
Projects
None yet
Development

No branches or pull requests

5 participants