From 88e1353d2fde75aa1c30c97b00243e968370bf46 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:09:34 +0200 Subject: [PATCH] Rename an internal parameter of _label_outer_x/yaxis() `check_patch` does not explain what this parameter is achieving. --- lib/matplotlib/axes/_base.py | 14 ++++++++------ lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/gridspec.py | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 9c2ba63901fd..24213a4570e3 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -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: @@ -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: diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 5da7e00d3ed9..ce263c3d8d1c 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -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* " diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index c86a527ef54a..b2f1b5d8ff2e 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -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