Skip to content

Commit b8bc55e

Browse files
committed
Fix includepanels axis label align when only 1 subplot present
1 parent 7d80f3d commit b8bc55e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

proplot/figure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def _get_align_axes(self, side):
778778
axs = [ax for ax in axs if ax.get_visible()]
779779
return axs
780780

781-
def _get_align_coord(self, side, axs):
781+
def _get_align_coord(self, side, axs, includepanels=False):
782782
"""
783783
Return the figure coordinate for centering spanning axis labels or super titles.
784784
"""
@@ -789,7 +789,7 @@ def _get_align_coord(self, side, axs):
789789
raise RuntimeError('Axes must be subplots.')
790790
s = 'y' if side in ('left', 'right') else 'x'
791791
axs = [ax._panel_parent or ax for ax in axs] # deflect to main axes
792-
if self._includepanels: # include panel short axes
792+
if includepanels: # include panel short axes?
793793
axs = [_ for ax in axs for _ in ax._iter_axes(panels=True, children=False)]
794794
ranges = np.array([ax._range_subplotspec(s) for ax in axs])
795795
min_, max_ = ranges[:, 0].min(), ranges[:, 1].max()
@@ -925,7 +925,7 @@ def _align_axis_label(self, x):
925925
if ax in seen or pos not in ('bottom', 'left'):
926926
continue # already aligned or cannot align
927927
axs = ax._get_span_axes(pos, panels=False) # returns panel or main axes
928-
if len(axs) == 1 or any(getattr(ax, '_share' + x) for ax in axs):
928+
if any(getattr(ax, '_share' + x) for ax in axs):
929929
continue # nothing to align or axes have parents
930930
seen.update(axs)
931931
if span or align:
@@ -968,7 +968,7 @@ def _align_super_title(self, renderer):
968968
return
969969
labs = tuple(t for t in self._suplabel_dict['top'].values() if t.get_text())
970970
pad = (self._suptitle_pad / 72) / self.get_size_inches()[1]
971-
x = self._get_align_coord('top', axs)[0]
971+
x, _ = self._get_align_coord('top', axs, includepanels=self._includepanels)
972972
y = self._get_offset_coord('top', axs, renderer, pad=pad, extra=labs)
973973
self._suptitle.set_ha('center')
974974
self._suptitle.set_va('bottom')
@@ -989,7 +989,7 @@ def _update_axis_label(self, side, axs):
989989

990990
# Get the central label and "super" label for parallel alignment.
991991
# Initialize the super label if one does not already exist.
992-
c, ax = self._get_align_coord(side, axs) # returns panel axes
992+
c, ax = self._get_align_coord(side, axs, includepanels=self._includepanels)
993993
axis = getattr(ax, x + 'axis') # use the central axis
994994
label = labs.get(ax, None)
995995
if label is None and not axis.label.get_text().strip():

0 commit comments

Comments
 (0)