Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update secondary_axis tutorial #29073

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 5 commits into from
Nov 21, 2024

Conversation

dkweiss31
Copy link
Contributor

@dkweiss31 dkweiss31 commented Nov 5, 2024

PR summary

Closes #29067
Fixes a small issue with the secondary_axis tutorial where the interpolation from one axis to the other needs to be defined outside the bounds of the data that is plotted. This was previously noted in the tutorial but was not implemented correctly. The example in question has been simplified and updated so that the secondary axis is correctly derived from the primary axis.

PR checklist

…rom the first. In this case the interpolation must be defined outside the bounds of the data that is plotted. Moreover the tutorial in question has been simplified.
@github-actions github-actions bot added the Documentation: examples files in galleries/examples label Nov 5, 2024
Copy link

@github-actions github-actions bot left a 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 us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

make endpoints large in magnitude

Co-authored-by: Jody Klymak <[email protected]>
@dkweiss31
Copy link
Contributor Author

Friendly bump @jklymak

secax = ax.secondary_xaxis('top', functions=(forward, inverse))
secax.xaxis.set_minor_locator(AutoMinorLocator())
secax.set_xlabel('$X_{other}$')
secax.set_xticks([10, 20, 40, 60, 80, 100])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: One could consider using the square numbers to make the relation even more obvious

Suggested change
secax.set_xticks([10, 20, 40, 60, 80, 100])
secax.set_xticks([4, 16, 36, 64, 100])

On the downside, this is proably slightly less "realistic", i.e. you would likely not find such tick positions in actual diagrams. Choose yourself, what you think is best.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might prefer the way it is now? Just since it (maybe) more closely corresponds to what you'd have in a real plot

dkweiss31 and others added 2 commits November 20, 2024 14:10
@timhoffm timhoffm added this to the v3.10.0 milestone Nov 21, 2024
@timhoffm timhoffm merged commit dcce480 into matplotlib:main Nov 21, 2024
22 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Nov 21, 2024
rcomer added a commit that referenced this pull request Nov 21, 2024
…073-on-v3.10.x

Backport PR #29073 on branch v3.10.x (Update secondary_axis tutorial)
ksunden pushed a commit to ksunden/matplotlib that referenced this pull request Nov 22, 2024
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
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[Bug]: secondary_xaxis produces ticks at incorrect locations
3 participants