-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Document change of label visibility on shared axes #10981
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
Document change of label visibility on shared axes #10981
Conversation
3ada949
to
72d20b0
Compare
I don't see the point of backporting to the 2.1 line; development there is closed. This would be backported to 2.2.x so as to land in 2.2.3. |
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 doing this so promptly. I have one recommendation and a minor correction.
doc/api/api_changes.rst
Outdated
hide tick labels instead of setting the visibility on the tick label objects. | ||
This improves overall performance and fixes some issues. | ||
As a consequence, in case those labels ought to be shown, `set_tick_params` | ||
needs to be used, e.g. `ax.xaxis.set_tick_params(labelbottom=True)`. |
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.
Here and in similar cases below: Is it worth adding the shorter alternative, ax.tick_params(labelbottom=True)
? Or giving that instead of the lower-level one? That would be my preference. I think it is easier for users to work with the single point of entry for manipulating tick-related things.
lib/matplotlib/figure.py
Outdated
axis object: | ||
squeeze : bool, optional, default: True | ||
- If True, extra dimensions are squeezed out from the returned Axes | ||
object: |
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.
Actually, dimensions are squeezed out of the ndarray of Axes objects, not out of any such object.
I'm not sure about the policy here; my thinking was simply if something got introduced in version x.y, the documentation of x.y should have it included, not the documentation of (x+1).(y+3). Of course this would only make sense if the respective documentation is then also rebuilt and put online, not sure if this would be the case. |
I don't think the documentation of any earlier version is going to be rebuilt--only the docs of future releases. The best you can do is note both the version when the change occurred, and the version when the documentation was updated accordingly. |
Internally, :func:`~matplotlib.axis.Axis.set_tick_params` is now used to | ||
hide tick labels instead of setting the visibility on the tick label objects. | ||
This improves overall performance and fixes some issues. | ||
As a consequence, in case those labels ought to be shown, `set_tick_params` |
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.
Here also, tick_params
.
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.
In the PR that changed that, they use Axis.set_tick_params
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.
I know, but saying "use set_tick_params
as in ax.tick_params(labelbottom=True)
is likely to make people think there is a typo somewhere. What's really going on internally is that the Tick.label1On parameter is being set, and this can be done at any point in a chain of calls starting with ax.tick_params.
I think the problem is actually starting with the first line; the use of Axis.set_tick_params is irrelevant, and the point is not that tick labels are being hidden in a different way when subplots are shared, but that instead of being flagged as invisible, they are simply not drawn at all. The user can turn label drawing on or off via, e.g., ax.tick_params(labelbottom=True)
.
lib/matplotlib/figure.py
Outdated
- If True, extra dimensions are squeezed out from the returned | ||
axis object: | ||
array of Axes object: |
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.
Axes objects (plural)
lib/matplotlib/pyplot.py
Outdated
- If True, extra dimensions are squeezed out from the returned Axes | ||
object: | ||
- If True, extra dimensions are squeezed out from the returned | ||
array of Axes object: |
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.
plural
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.
I really shouldn't have touched this squeeze parameter at all. 😆
Anyways, as I understand the sentence it is "Extra dimensions are squeezed out from the returned
object." (singular)
Now which object is that more specifically? It is an (array of Axes)-object.
If that should not be the case, could you please suggest the propper wording, because not being a native speaker, I wouldn't know how to write this differently.
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.
My comment was unclear. I meant "array of Axes object" -> "array of Axes objects".
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.
In that case my above comment would still apply. subplots
returns one single array. That array is one single object.
But I now understand the issue. So I guess both ways are correct, depending on what you want to say.
This can be an (array of Axes)-object.
Or it can be an array of (Axes-objects).
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.
What about leaving the object out completely?
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.
I’d say “extra dimensions from the two-d array of axes are squeezed out.”
I see. Do you think this to be necessary? (It would look strange in the middle of a docstring, right?) |
I think he just means in the API change note. ...but - is it ok to back-change these documents this way? I'd not expect to see the API changes and whats new be different between different versions of the docs. |
Since the docs reside in the same repo as the code, I don't see how it would make sense to update the docs in a closed branch, without reopening it and releasing with a new tag; the docs would be out of sync with the repo as of the last tagged release on that branch. We aren't going to have any more tags and releases on 2.1, so I think we are stuck. It won't be the only less-than-perfect aspect of the docs for 2.1, or for any other version, for that matter. |
Yeah, I meant the other way, that these should be just put at the top of the whats new and API changes |
be0f403
to
8977953
Compare
I'm not 100% sure if I follow the arguments here. Is there anything more I should do for this PR? |
@efiring is this OK w/ you? |
Still not sure about the branch policy, but AFAIK this has to go into v2.2.3 instead of v2.2.-doc because it changes .py files (even if those changes are only in docstrings). Please correct me, if I'm wrong here. |
That’s correct (though I didn’t realize this until yesterday) |
Backport PR #10981 on branch v2.2.x
PR Summary
In #8678 internal use of
Axis.set_tick_params
has been introduced to some methods previously using the ticklabels properties themselves. This change has led to the labels of shared axes not be turned invisible, but instead not being created at all. Previously working ways to turn the labels visible again are therefore failing, see Get ticklabels back on shared axis #10911.This PR partially fixes #10911 in the sense of creating a what's new entry for this change and updating the documentation of
sharex
.If possible it should be backported to 2.1.0 where this change was silently introduced.
Note that further actions might be required to fully introduce
set_tick_params
as viable alternative to setting individual artist properties. Those go beyond the scope of this PR and should probably be introduced as new features.PR Checklist