Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e26a517

Browse files
jklymakMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR matplotlib#10981: Document change of label visibility on shared axes
1 parent aa87ae3 commit e26a517

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

doc/api/api_changes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,22 @@ Both bindings are disabled if only a subset of the grid lines (in either
407407
direction) is visible, to avoid making irreversible changes to the figure.
408408

409409

410+
Ticklabels are turned off instead of being invisible
411+
----------------------------------------------------
412+
413+
Internally, the `Tick`'s :func:`~matplotlib.axis.Tick.label1On` attribute
414+
is now used to hide tick labels instead of setting the visibility on the tick
415+
label objects.
416+
This improves overall performance and fixes some issues.
417+
As a consequence, in case those labels ought to be shown,
418+
:func:`~matplotlib.axes.Axes.tick_params`
419+
needs to be used, e.g.
420+
421+
::
422+
423+
ax.tick_params(labelbottom=True)
424+
425+
410426
Removal of warning on empty legends
411427
-----------------------------------
412428

doc/users/prev_whats_new/whats_new_2.1.0.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,28 @@ cases.
395395
---------------------------------------------------
396396

397397
Bulk setting of tick label rotation is now possible via
398-
:func:`~matplotlib.axis.Axis.set_tick_params` using the ``rotation``
398+
:func:`~matplotlib.axes.Axes.tick_params` using the ``rotation``
399399
keyword.
400400

401401
::
402402

403-
ax.xaxis.set_tick_params(which='both', rotation=90)
403+
ax.tick_params(which='both', rotation=90)
404+
405+
406+
Ticklabels are turned off instead of being invisible
407+
----------------------------------------------------
408+
409+
Internally, the `Tick`'s :func:`~matplotlib.axis.Tick.label1On` attribute
410+
is now used to hide tick labels instead of setting the visibility on the tick
411+
label objects.
412+
This improves overall performance and fixes some issues.
413+
As a consequence, in case those labels ought to be shown,
414+
:func:`~matplotlib.axes.Axes.tick_params`
415+
needs to be used, e.g.
416+
417+
::
418+
419+
ax.tick_params(labelbottom=True)
404420

405421

406422
Shading in 3D bar plots

lib/matplotlib/figure.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,21 +1266,21 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
12661266
- 'col': each subplot column will share an x- or y-axis.
12671267
12681268
When subplots have a shared x-axis along a column, only the x tick
1269-
labels of the bottom subplot are visible. Similarly, when
1270-
subplots have a shared y-axis along a row, only the y tick labels
1271-
of the first column subplot are visible.
1269+
labels of the bottom subplot are created. Similarly, when subplots
1270+
have a shared y-axis along a row, only the y tick labels of the
1271+
first column subplot are created. To later turn other subplots'
1272+
ticklabels on, use :meth:`~matplotlib.axes.Axes.tick_params`.
12721273
1273-
squeeze : bool, default: True
1274+
squeeze : bool, optional, default: True
12741275
- If True, extra dimensions are squeezed out from the returned
1275-
axis object:
1276+
array of Axes:
12761277
12771278
- if only one subplot is constructed (nrows=ncols=1), the
12781279
resulting single Axes object is returned as a scalar.
1279-
- for Nx1 or 1xN subplots, the returned object is a 1D numpy
1280-
object array of Axes objects are returned as numpy 1D
1281-
arrays.
1282-
- for NxM, subplots with N>1 and M>1 are returned as a 2D
1283-
arrays.
1280+
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1281+
object array of Axes objects.
1282+
- for NxM, subplots with N>1 and M>1 are returned
1283+
as a 2D array.
12841284
12851285
- If False, no squeezing at all is done: the returned Axes object
12861286
is always a 2D array containing Axes instances, even if it ends

lib/matplotlib/pyplot.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,19 +1091,20 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10911091
- 'col': each subplot column will share an x- or y-axis.
10921092
10931093
When subplots have a shared x-axis along a column, only the x tick
1094-
labels of the bottom subplot are visible. Similarly, when subplots
1094+
labels of the bottom subplot are created. Similarly, when subplots
10951095
have a shared y-axis along a row, only the y tick labels of the first
1096-
column subplot are visible.
1096+
column subplot are created. To later turn other subplots' ticklabels
1097+
on, use :meth:`~matplotlib.axes.Axes.tick_params`.
10971098
10981099
squeeze : bool, optional, default: True
1099-
- If True, extra dimensions are squeezed out from the returned Axes
1100-
object:
1100+
- If True, extra dimensions are squeezed out from the returned
1101+
array of Axes:
11011102
11021103
- if only one subplot is constructed (nrows=ncols=1), the
11031104
resulting single Axes object is returned as a scalar.
1104-
- for Nx1 or 1xN subplots, the returned object is a 1D numpy
1105-
object array of Axes objects are returned as numpy 1D arrays.
1106-
- for NxM, subplots with N>1 and M>1 are returned as a 2D arrays.
1105+
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1106+
object array of Axes objects.
1107+
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
11071108
11081109
- If False, no squeezing at all is done: the returned Axes object is
11091110
always a 2D array containing Axes instances, even if it ends up

0 commit comments

Comments
 (0)