Skip to content

Fix example for rcParams['autolimit_mode'] #20514

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

Merged
merged 1 commit into from
Jul 5, 2021

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jun 25, 2021

PR Summary

@anntzer
Copy link
Contributor

anntzer commented Jun 29, 2021

I'm a bit confused by the last example. In the rendered docs (https://61232-1385122-gh.circle-artifacts.com/0/doc/build/html/gallery/ticks_and_spines/auto_ticks.html#sphx-glr-gallery-ticks-and-spines-auto-ticks-py) it seems that the limits don't extend to -0.5/+2.0, i.e. the closest round numbers, but if I run the example locally then they do (certainly, the ticks appear). Perhaps a bad interaction with sphinx-gallery? (ie. perhaps s-g always exits the last block before rendering the last figure?)

@timhoffm
Copy link
Member Author

I'm a bit confused by the last example. In the rendered docs (https://61232-1385122-gh.circle-artifacts.com/0/doc/build/html/gallery/ticks_and_spines/auto_ticks.html#sphx-glr-gallery-ticks-and-spines-auto-ticks-py) it seems that the limits don't extend to -0.5/+2.0, i.e. the closest round numbers, but if I run the example locally then they do (certainly, the ticks appear). Perhaps a bad interaction with sphinx-gallery? (ie. perhaps s-g always exits the last block before rendering the last figure?)

Indeed also the second example is not rendered correctly in the docs. Both are fine when executed locally. I suspect that the problem is that sphinx-gallery has to do a savefig() which is by construction outside the context manager. I don't think there's anything we can do about that.
Anyway, I'd argue this PR is still an improvement because the code itself now works when people are copying it.

@anntzer
Copy link
Contributor

anntzer commented Jun 30, 2021

I suspect that the problem is that sphinx-gallery has to do a savefig() which is by construction outside the context manager.

Ah, likely yes.

I think you can just set the rcParams globally for the second half of the example?

@timhoffm timhoffm force-pushed the doc-autolimit_mode branch 4 times, most recently from 967557d to f45bcfd Compare July 3, 2021 23:42
@anntzer
Copy link
Contributor

anntzer commented Jul 4, 2021

doc failure is real

AttributeError: 'AxesSubplot' object has no attribute 'set_xmargins'

@timhoffm timhoffm force-pushed the doc-autolimit_mode branch from f45bcfd to 1a036aa Compare July 4, 2021 16:01
@timhoffm
Copy link
Member Author

timhoffm commented Jul 4, 2021

Fixed.

@QuLogic QuLogic merged commit 5faa1bb into matplotlib:master Jul 5, 2021
@QuLogic QuLogic added this to the v3.5.0 milestone Jul 5, 2021
@timhoffm timhoffm deleted the doc-autolimit_mode branch July 6, 2021 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rcParams['axes.autolimit_mode'] = 'round_numbers' is broken
3 participants