Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
ENH: call update_ticks before we return them to the user#20345
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This one is pretty basic; if someone asks for the ticks on an axis, I don't see why we would force them to do a whole draw... |
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.
That this is so basic makes me suspicious: Why haven't we done such a simple thing before?
My first guess "we use it heavily in the codebase (and it thus might be a performance issue)" is not correct. Apart from one usage inSecondaryAxis
this is only used in tests an a tutorial. Why? Because internally we useget_minorticklocs()
andget_majorticklocs()
. Since both of them are public API as well, they should have the same update state asget_ticklocs()
. I.e. if we update that should happen in there.
Now, I'm not sure what the implication of that would be._update_ticks()
queriesget_minorticklocs()
andget_majorticklocs()
so we'd need to have a closer look on that cyclic usage. It might also be the case that we should make the currentget_major/minorticklocs
private for internal use without update and have change the public variants to use updates.
Anyway I'm afraid only adding_update_ticks()
here is too simple.
I'm actually confused now what prompted this. Going back to 3.3.0 importmatplotlib.pyplotaspltimportnumpyasnpfig,ax=plt.subplots()ax.plot(np.arange(100))print(ax.xaxis.get_majorticklocs())print(ax.xaxis.get_minorticklocs())print(ax.get_xticks()) works as expected. So I'll close this until we can remember why this was an issue. |
This was re-done by#23170, because it wasn't really working as stated above. |
PR Summary
Currently,
get_x/yticks
doesn't work until a draw is called. But we can update the ticks, so why not?PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).