Skip to content

Commit 28eaf0c

Browse files
committed
Fix panel sharing issue with stacked panels
1 parent cf0d5d4 commit 28eaf0c

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

docs/insets_panels.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
#
2828
# It is often useful to have narrow "panels" along the edge of a larger
2929
# subplot for plotting secondary 1-dimensional datasets or summary statistics.
30-
# In matplotlib, there is no simple way to do this. In ProPlot, you can
31-
# create panels by passing a location (e.g. ``loc='r'`` or ``loc='right'``)
32-
# to the `~proplot.axes.Axes.panel` or `~proplot.axes.Axes.panel_axes` methods.
33-
# The resulting axes are instances of `~proplot.axes.CartesianAxes`.
30+
# In ProPlot, you can create panels by passing a location (e.g. ``loc='r'`` or
31+
# ``loc='right'``) to the `~proplot.axes.Axes.panel` or `~proplot.axes.Axes.panel_axes`
32+
# methods. The resulting axes are instances of `~proplot.axes.CartesianAxes`.
3433
#
3534
# To generate "stacked" panels, simply call `~proplot.axes.Axes.panel` more
3635
# than once. To include panels when centering spanning axis labels and super
@@ -100,8 +99,7 @@
10099
axs.format(
101100
xlim=(0, 1), ylim=(0, 1),
102101
xlabel='xlabel', ylabel='ylabel',
103-
yticks=plot.arange(0.2, 0.8, 0.2),
104-
xticks=plot.arange(0.2, 0.8, 0.2),
102+
xticks=0.2, yticks=0.2,
105103
title='Title', suptitle='Complex arrangement of panels',
106104
collabels=['Column 1', 'Column 2'],
107105
abc=True, abcloc='ul', titleloc='uc', abovetop=False,

proplot/axes/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,15 @@ def _is_panel(self):
435435
"""
436436
return bool(self._panel_parent)
437437

438-
def _is_panel_parent_or_child(self, other):
438+
def _is_panel_group_member(self, other):
439439
"""
440440
Return whether the axes are related.
441441
"""
442-
return self._panel_parent is other or other._panel_parent is self
442+
return (
443+
self._panel_parent is other # child
444+
or other._panel_parent is self # parent
445+
or other._panel_parent is self._panel_parent # sibling
446+
)
443447

444448
def _loc_translate(self, loc, mode=None, allow_manual=True):
445449
"""

proplot/axes/cartesian.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ def _apply_axis_sharing(self):
268268
at drawtime, "shared" labels can be inadvertantly turned off.
269269
"""
270270
# X axis
271+
# NOTE: The "panel sharing group" refers to axes and panels *above* the
272+
# bottommost or to the *right* of the leftmost panel. But the edge panel
273+
# sharing level is the *figure* sharing level.
271274
axis = self.xaxis
272275
if self._sharex is not None:
273276
level = 3 if self._panel_sharex_group else self.figure._sharex
@@ -372,7 +375,7 @@ def _sharex_setup(self, sharex):
372375

373376
# Get sharing level
374377
level = (
375-
3 if self._panel_sharex_group and self._is_panel_parent_or_child(sharex)
378+
3 if self._panel_sharex_group and self._is_panel_group_member(sharex)
376379
else self.figure._sharex
377380
)
378381
if level not in range(4):
@@ -431,7 +434,7 @@ def _sharey_setup(self, sharey):
431434

432435
# Get sharing level
433436
level = (
434-
3 if self._panel_sharey_group and self._is_panel_parent_or_child(sharey)
437+
3 if self._panel_sharey_group and self._is_panel_group_member(sharey)
435438
else self.figure._sharey
436439
)
437440
if level not in range(4):

0 commit comments

Comments
 (0)