Skip to content

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

Conversation

ImportanceOfBeingErnest
Copy link
Member

@ImportanceOfBeingErnest ImportanceOfBeingErnest commented Apr 7, 2018

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

  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@ImportanceOfBeingErnest ImportanceOfBeingErnest force-pushed the doc-labelvisibility-on-shared-axes branch from 3ada949 to 72d20b0 Compare April 7, 2018 23:32
@efiring
Copy link
Member

efiring commented Apr 8, 2018

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.

@jklymak jklymak added this to the v2.2-doc milestone Apr 8, 2018
Copy link
Member

@efiring efiring 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 doing this so promptly. I have one recommendation and a minor correction.

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)`.
Copy link
Member

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.

axis object:
squeeze : bool, optional, default: True
- If True, extra dimensions are squeezed out from the returned Axes
object:
Copy link
Member

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.

@ImportanceOfBeingErnest
Copy link
Member Author

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.

@efiring
Copy link
Member

efiring commented Apr 8, 2018

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`
Copy link
Member

Choose a reason for hiding this comment

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

Here also, tick_params.

Copy link
Member Author

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

Copy link
Member

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).

- If True, extra dimensions are squeezed out from the returned
axis object:
array of Axes object:
Copy link
Member

Choose a reason for hiding this comment

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

Axes objects (plural)

- 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:
Copy link
Member

Choose a reason for hiding this comment

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

plural

Copy link
Member Author

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.

Copy link
Member

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".

Copy link
Member Author

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).

Copy link
Member Author

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?

Copy link
Member

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.”

@ImportanceOfBeingErnest
Copy link
Member Author

I see. Do you think this to be necessary? (It would look strange in the middle of a docstring, right?)

@jklymak
Copy link
Member

jklymak commented Apr 8, 2018

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.

@efiring
Copy link
Member

efiring commented Apr 8, 2018

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.

@jklymak
Copy link
Member

jklymak commented Apr 8, 2018

Yeah, I meant the other way, that these should be just put at the top of the whats new and API changes

@ImportanceOfBeingErnest ImportanceOfBeingErnest force-pushed the doc-labelvisibility-on-shared-axes branch from be0f403 to 8977953 Compare April 8, 2018 20:14
@ImportanceOfBeingErnest
Copy link
Member Author

I'm not 100% sure if I follow the arguments here. Is there anything more I should do for this PR?

@jklymak
Copy link
Member

jklymak commented Apr 24, 2018

@efiring is this OK w/ you?

@timhoffm timhoffm modified the milestones: v2.2-doc, v2.2.3 Apr 24, 2018
@timhoffm
Copy link
Member

timhoffm commented Apr 24, 2018

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.

@jklymak
Copy link
Member

jklymak commented Apr 24, 2018

That’s correct (though I didn’t realize this until yesterday)

@jklymak jklymak merged commit 0984694 into matplotlib:master Apr 25, 2018
jklymak added a commit that referenced this pull request Apr 26, 2018
@ImportanceOfBeingErnest ImportanceOfBeingErnest deleted the doc-labelvisibility-on-shared-axes branch May 10, 2018 15:50
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.

Get ticklabels back on shared axis
4 participants