10000 Document change of label visibility on shared axes by ImportanceOfBeingErnest · Pull Request #10981 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/api/api_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ Both bindings are disabled if only a subset of the grid lines (in either
direction) is visible, to avoid making irreversible changes to the figure.


Ticklabels are turned off instead of being invisible
----------------------------------------------------

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



Removal of warning on empty legends
-----------------------------------

Expand Down
10 changes: 10 additions & 0 deletions doc/users/prev_whats_new/whats_new_2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ keyword.
ax.xaxis.set_tick_params(which='both', rotation=90)


Ticklabels are turned off instead of being invisible
----------------------------------------------------

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

needs to be used, e.g. `ax.xaxis.set_tick_params(labelbottom=True)`.


Shading in 3D bar plots
-----------------------

Expand Down
22 changes: 11 additions & 11 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,21 +1265,21 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
- 'col': each subplot column will share an x- or y-axis.

When subplots have a shared x-axis along a column, only the x tick
labels of the bottom subplot are visible. Similarly, when
subplots have a shared y-axis along a row, only the y tick labels
of the first column subplot are visible.
labels of the bottom subplot are created. Similarly, when subplots
have a shared y-axis along a row, only the y tick labels of the
first column subplot are created. To later turn other subplots'
ticklabels on, use :meth:`~matplotlib.axis.Axis.set_tick_params`.

squeeze : bool, default: True
- If True, extra dimensions are squeezed out from the returned
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.


- if only one subplot is constructed (nrows=ncols=1), the
resulting single Axes object is returned as a scalar.
- for Nx1 or 1xN subplots, the returned object is a 1D numpy
object array of Axes objects are returned as numpy 1D
arrays.
- for NxM, subplots with N>1 and M>1 are returned as a 2D
arrays.
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
object array of Axes objects.
- for NxM, subplots with N>1 and M>1 are returned
as a 2D array.

- If False, no squeezing at all is done: the returned Axes object
is always a 2D array containing Axes instances, even if it ends
Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,19 +1012,20 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
- 'col': each subplot column will share an x- or y-axis.

When subplots have a shared x-axis along a column, only the x tick
labels of the bottom subplot are visible. Similarly, when subplots
labels of the bottom subplot are created. Similarly, when subplots
have a shared y-axis along a row, only the y tick labels of the first
column subplot are visible.
column subplot are created. To later turn other subplots' ticklabels
on, use :meth:`~matplotlib.axis.Axis.set_tick_params`.

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

- if only one subplot is constructed (nrows=ncols=1), the
resulting single Axes object is returned as a scalar.
- for Nx1 or 1xN subplots, the returned object is a 1D numpy
object array of Axes objects are returned as numpy 1D arrays.
- for NxM, subplots with N>1 and M>1 are returned as a 2D arrays.
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
object array of Axes objects.
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.

- If False, no squeezing at all is done: the returned Axes object is
always a 2D array containing Axes instances, even if it ends up
Expand Down
0