Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
[fix] Spine.set_bounds() does not take parameter **None** as expected#30330
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
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
Thanks for the contribution@leakyH! I confirm I can reproduce the behaviour you report with importmatplotlib.pyplotaspltimportnumpyasnp# Sample datax=np.linspace(10,20,100)y=np.sin(x)fig,ax=plt.subplots()ax.plot(x,y)ax.spines['bottom'].set_bounds(10,None)plt.show() ![]() It looks like you are still working on your fix, so I'm going to mark this as "draft" for now. Please mark it as "ready for review" when you are ready. |
Thank you@rcomer ! I just found that one of the tests failed, because I modified the self._bounds in the get_bounds() function in my original fix. Now I've solve it and I will mark it as "ready for review" when all tests pass! |
rcomer commentedJul 18, 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.
Edited because actually this behaviour is consistent with Thanks for your work on this@leakyH. importmatplotlib.pyplotaspltimportnumpyasnp# Sample datax=np.linspace(10,20,100)y=np.sin(x)fig,ax=plt.subplots()ax.plot(x,y)ax.spines['bottom'].set_bounds(10,None)ax.plot(x*2,y)plt.show() with your branch, this now gives
I also note that I wonder if the issue might be fixed more simply by only changing the way |
yes@rcomer , thank you for your inspiring review, and I know what you mean now.
Certainly, we can change the documentation after all. I just want to make sure you notice that and this is what we want. Since this As a reference, please run this code:
You'll see theNone for xlim also means to keep the original xlim, and does not change for later
I think the easiest way is to modify the Thank you! |
Thank you for thinking this through! You are right and I actually had not realised that |
Hi@rcomer , I've updated the code:
And to whom may concern, this PR initailly processed the |
Uh oh!
There was an error while loading.Please reload this page.
PR summary
The spines.set_bounds() can take None as input, as stated in the doc,
, but it turns out it leaves a None to the spine's low or high,because it get one None from get_bounds() by default, then the spine is invisible.
I modify the get_bounds() function's behavior, so that it can return real original bound for set_bounds() function, when self._bounds is None. Note that the get_bounds() function shouldNOT modify the self._bounds even if it's None.
The code I added was originally in the _adjust_location() function (and I replace the original code with get_bounds()). So the modification should be harmless.
A small demo for the problem, and you should see the bottom spine of ax1 disappear for no reason.
The code is tested with pre-commit in a Codespace environment.
PR checklist