Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add example to histogram colorbar on galleries#30107
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
@story645 thanks for the suggestion! This PR is ready for review |
It looks like something went wrong with the layout. Also, please read the comments on the issue for ideas how to improve this. |
livlutz commentedMay 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
thanks for the feedback, I tried to make some adjustments but I cannot see if my changes were successful, how does this link you commented before work? |
rcomer commentedMay 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
At the bottom of this page are some automated checks. Scroll to the bottom of them and you see "View the built docs". Click on that and you can then navigate to your example from there. But you can also just run your script locally to see how the plot looks. That will give you faster feedback. |
story645 left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
As@rcomer said, please look at the original issue - particularly the suggestion to use binomially distributed data .
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
…ayout, and adjust label positions
Thanks a lot for all the suggestions, I tried to see the changes locally like@rcomer said and it should look much better now, please let me know if there's still something missing |
story645 commentedMay 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Can you please try the dataset@jklymak suggested in the original issue? Also can you remove the spines (code should also be in the original example). Also please remove the yaxis_inversion as that's confusing me here - it might be clearer if you add the colorbar like in the original issue. Which also setting the margins to 0 (see original example) will remove the spacing for the bar chart so that it takes up the whole space (also please set height to 100% so they line up) - you are welcome to add that as a comment if it makes it clearer and to ask about the purpose of any code you don't understand. |
…) + remove yaxis inversion
I tried the first example from here :https://matplotlib.org/devdocs/gallery/images_contours_and_fields/image_demo.html and it worked just fine! please tell me if it is alright now |
story645 commentedMay 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The new dataset isn't a normal distribution so the histogram should also not be a normal distribution. Please check your bins and extents (for example the dark blue and dark orange should be more prominent). Please plot the histogram without preset bins so that you can see what it's supposed to look like and then follow the example in the original issue for visualizing the correct histogram. Please ask questions if you don't understand the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Also please remove the spines and margins from the histogram.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I took a look at the original issue but it says the new dataset is a bivariate normal distribution, should I still change the histogram? And I'm a bit confused about the extents, do you have any suggestions on what changes should I make? |
…, improve inset axes layout, and enhance label spacing
I changed the histogram slightly so it depicts a bivariate normal distribuition, please tell me if I still need to fix anything |
Yes and it looks slightly different from the output I got when I ran the program locally...does it have to do with the output screen scale? |
story645 commentedMay 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just that for the visualization it would maybe be less busy if there are fewer bins but it's not a big deal/blocker. |
The still has linting errors, and the word "count" is not fitting in the figure, so you can either manually mess with the sizes, or use |
If it's too busy, I'd just get rid of the spacing between the bars. |
I managed to fix most of the linting errors, but something is happening with mypy and I am not really sure I understand what is going on |
@story645 Hello, so I heard a lot of people are having trouble with mypy linting errors due to an update so I was just wondering what will happen to this PR later on since many people (including me) are stuck on that |
The mypy problems have been fixed on the main branch. It might be enough to close and re-open the PR to pick up those changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Overall, the commenting feels a bit too noisy. Please recheck with ourexample guidelines and see if you can improve a bit.
I have the impression that comments are used to create sections with headings (# === Surface Data ===
). IMHO that's too much for examples. The code should mostly be able to stand for itself. If comments are used, they should be an explantion, i.e. you'd typically write# surface data
but not# === Surface Data ===
.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the help! I managed to get rid of linting errors (finally!) so this is ready for review. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I applied the suggested changes and I also checked how it looks like on the built docs and everything looks alright, do we need to change anything else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Gerneally, please lowercase the comments. As said, they are not section titles but remarks.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I'm just getting an error in line 30 : line 30, in I am not really sure what it means and I think we should change the parameters |
Uh oh!
There was an error while loading.Please reload this page.
Thank you for the help, I managed to fix it now! Hopefully it works alright now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Only minor formatting comments left.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
cax = ax.inset_axes([1.18, 0.02, 0.25, 0.95]) # left, bottom, width, height | ||
# plot histogram | ||
counts, bin_edges = np.histogram(Z, bins=bins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
counts,bin_edges=np.histogram(Z,bins=bins) | |
counts,_=np.histogram(Z,bins=bin_edges) |
Sorry, I just realized, we can make this now slightly safer/more obvious by using the existingbin_edges
and not letnp.histogram
create them anew, hoping they are identical to the explicit calculation above.
Is there anything else left to change? |
PR summary
This PR contains an example code for generating histogram colorbar on the galleries section with a reference to it on the readme file
closes#30026
PR checklist