Skip to content

Commit

Permalink
Rename an internal parameter of _label_outer_x/yaxis()
Browse files Browse the repository at this point in the history
`check_patch` does not explain what this parameter is achieving.
  • Loading branch information
timhoffm committed Aug 5, 2023
1 parent d073a36 commit 88e1353
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4498,12 +4498,13 @@ def label_outer(self):
labels are on the top side); y-labels only for subplots on the first
column (or last column, if labels are on the right side).
"""
self._label_outer_xaxis(check_patch=False)
self._label_outer_yaxis(check_patch=False)
self._label_outer_xaxis(skip_non_rectangular_axes=False)
self._label_outer_yaxis(skip_non_rectangular_axes=False)

def _label_outer_xaxis(self, *, check_patch):
def _label_outer_xaxis(self, *, skip_non_rectangular_axes):
# see documentation in label_outer.
if check_patch and not isinstance(self.patch, mpl.patches.Rectangle):
if skip_non_rectangular_axes and not isinstance(self.patch,
mpl.patches.Rectangle):
return
ss = self.get_subplotspec()
if not ss:
Expand All @@ -4522,9 +4523,10 @@ def _label_outer_xaxis(self, *, check_patch):
if self.xaxis.offsetText.get_position()[1] == 0:
self.xaxis.offsetText.set_visible(False)

def _label_outer_yaxis(self, *, check_patch):
def _label_outer_yaxis(self, *, skip_non_rectangular_axes):
# see documentation in label_outer.
if check_patch and not isinstance(self.patch, mpl.patches.Rectangle):
if skip_non_rectangular_axes and not isinstance(self.patch,
mpl.patches.Rectangle):
return
ss = self.get_subplotspec()
if not ss:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,10 +2118,10 @@ def _do_layout(gs, mosaic, unique_ids, nested):
for ax in ret.values():
if sharex:
ax.sharex(ax0)
ax._label_outer_xaxis(check_patch=True)
ax._label_outer_xaxis(skip_non_rectangular_axes=True)
if sharey:
ax.sharey(ax0)
ax._label_outer_yaxis(check_patch=True)
ax._label_outer_yaxis(skip_non_rectangular_axes=True)
if extra := set(per_subplot_kw) - set(ret):
raise ValueError(
f"The keys {extra} are in *per_subplot_kw* "
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
# turn off redundant tick labeling
if sharex in ["col", "all"]:
for ax in axarr.flat:
ax._label_outer_xaxis(check_patch=True)
ax._label_outer_xaxis(skip_non_rectangular_axes=True)
if sharey in ["row", "all"]:
for ax in axarr.flat:
ax._label_outer_yaxis(check_patch=True)
ax._label_outer_yaxis(skip_non_rectangular_axes=True)

if squeeze:
# Discarding unneeded dimensions that equal 1. If we only have one
Expand Down

0 comments on commit 88e1353

Please sign in to comment.