-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add Axes.get_tick_params()
method.
#23692
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
Conversation
I believe that this can be one way to go, subject to the caveats in #23603 (comment) I think that there should be a copy of the dictionary returned and that there should be a comment that only those parameters deviating from the default (and/or rcParams?) are returned. (There should probably also be a version in mplot3d for Axes including a zaxis, but that can be extended in a different PR later.) |
Based on #23633 one may also opt for skipping the |
@stefmolin sorry for letting this slip. I'm tempted to only add As opposed to the setter, which can set both Axis, and thus can save code, the getter has to resolve to exactly one axis and thus We should cross-ref in the docs of A very central part of this, is communicating the meaning of these parameters: They are the default values, i.e. if new ticks are created (e.g. by panning or zooming) these values are used for the new ticks. This is in contrast with the actual tick values (the properties of the current tick objects), which can in principle be overwritten by the user. |
Works for me; I removed the extra method.
I updated the docstrings for this – let me know what you think.
Not sure what you mean by this. Are you referring to updating a docstring or code? |
Axes.get_tick_params()
method.Axes.get_tick_params()
method.
The larger point is that we are not clear in distinguishing between the concept of a Axis-wide default tick style (stored in I'm not sure whether documentation or code is the the right way forward. With documentation, we can explain everything in detail. OTOH we could also try to move the user away from interacting with or thinking about single ticks (#23372), which might make a detailed explanation of the topic unnecessary. This would be part code part documentation. On a side note, the latter would also be in line with ideas for internal refactoring that should increase performance (#5665 (comment)). |
One additional complication I just noted is that the internal names in matplotlib/lib/matplotlib/axis.py Line 948 in 3b79f63
We have to either translate back for I'm sorry this is a bit of a mess. |
@timhoffm – Is there a preference? I can see these being confusing if you get them back: matplotlib/lib/matplotlib/axis.py Lines 1009 to 1016 in 3b79f63
The rest are probably fine. What do you think? |
Uh, this is a difficult decision. I'm tempted to translate back. I think the docstring https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.tick_params.html#matplotlib.axes.Axes.tick_params is the only user-visible place where we document what can go in (we currently accept more, but that somewhat coincidence). In that sense, This back-and forth converting is a bit annoying internally, but I think it is the most logical and consistent interface we can offer here. |
I added a reverse option to the |
@timhoffm - Any ideas what is going on for the docs per this comment above? Some additional questions on documentation for this PR:
|
Please add an entry to
You can try and add an Example section to the docstring. I would not make an addition to the Example Gallery. I hope this is correct, because it'S only from memory - please ignore if I'm wrong: It may be a bit confusing because AFAIR there are a few entries in _major_tick_kw by default. But we're stating that this only contains deviations from defaults (having "deviations from defaults" by default is a bit awkward). OTOH it may make sense to spell this out.
Yes, please.
No API change note, because our public API has not changed. |
|
@timhoffm What do you mean by this? Was this meant for another PR? |
Yes, sorry! 🐑 |
Yeah, there are a few entries in there by default. I agree the phrasing is a little confusing. I modified the docstrings to indicate that we are returning the appearance of any new elements that will be added without calling out defaults – hopefully, that makes it easier to understand. I also added the example to the docstring and what's new entry. |
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.
Just a few documentation suggestions. I didn't read the history, but the docs refer to a mysterious "default style" which to me are the rcParam values, not the values currently on the axis. I think you are trying to differentiate between manual ticks and those styles automatically, but I think the note gets that across adequately. People don't often much with individual ticks, so I'd argue not to muddy the waters of the main docstrings with a rare case.
Co-authored-by: Jody Klymak <jklymak@gmail.com>
Should I also add the |
@jklymak - I added the |
Thank you @stefmolin ! |
@@ -988,19 +1051,27 @@ def _translate_tick_params(kw): | |||
'labelright': 'label2On', | |||
'labeltop': 'label2On', |
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.
labelleft & labelbottom have the same axis key, the translation will therefore always return labelleft
and labelright
, also for the x-axis. This is confusing.
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.
Please open a new issue with the details of what you are seeing.
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.
Ok, done, see #28772
PR Summary
Addresses #23603
Axis.get_tick_params()
method, which will returnAxis._major_tick_kw
orAxis._minor_tick_kw
depending on the value ofwhich
Axes.get_tick_params()
method, which will return the result ofAxis.get_tick_params()
on theaxis
specified and error out ifboth
is passed inPR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).