Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions ultraplot/axes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,22 +1347,24 @@ def shared(paxs):

# External axes sharing, sometimes overrides panel axes sharing
# Share x axes within compatible groups
axes_x = self._get_share_axes("x")
for group in self.figure._partition_share_axes(axes_x, "x"):
if not group:
continue
parent, *children = group
for child in children:
child._sharex_setup(parent)
if self.figure._sharex > 0:
axes_x = self._get_share_axes("x")
for group in self.figure._partition_share_axes(axes_x, "x"):
if not group:
continue
parent, *children = group
for child in children:
child._sharex_setup(parent)

# Share y axes within compatible groups
axes_y = self._get_share_axes("y")
for group in self.figure._partition_share_axes(axes_y, "y"):
if not group:
continue
parent, *children = group
for child in children:
child._sharey_setup(parent)
if self.figure._sharey > 0:
axes_y = self._get_share_axes("y")
for group in self.figure._partition_share_axes(axes_y, "y"):
if not group:
continue
parent, *children = group
for child in children:
child._sharey_setup(parent)

# Global sharing, use the reference subplot where compatible
ref = self.figure._subplot_dict.get(self.figure._refnum, None)
Expand Down
9 changes: 9 additions & 0 deletions ultraplot/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,15 @@ def _share_ticklabels(self, *, axis: str) -> None:

# Process each group independently
for _, group_axes in groups.items():
# Nothing to share if the group is too small or sharing is disabled —
# avoids unsupported-type warnings (e.g. PolarAxes) for those cases.
if len(group_axes) < 2:
continue
if all(
self._effective_share_level(axi, axis, sides) < 3 for axi in group_axes
):
continue

# Build baseline from MAIN axes only (exclude panels)
baseline, skip_group = self._compute_baseline_tick_state(
group_axes, axis, label_keys
Expand Down
50 changes: 50 additions & 0 deletions ultraplot/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,56 @@ def test_explicit_share_warns_for_mixed_cartesian_polar():
assert len(incompatible) == 1


def test_share_zero_polar_emits_no_warnings(recwarn):
fig, axs = uplt.subplots(proj="polar", ncols=2, nrows=3, share=0)
fig.canvas.draw()

ultra = [
w
for w in recwarn
if issubclass(w.category, uplt.internals.warnings.UltraPlotWarning)
]
assert ultra == [], [str(w.message) for w in ultra]


def test_share_zero_mixed_cartesian_polar_emits_no_warnings(recwarn):
fig, axs = uplt.subplots(ncols=2, proj=("cart", "polar"), share=0)
fig.canvas.draw()

ultra = [
w
for w in recwarn
if issubclass(w.category, uplt.internals.warnings.UltraPlotWarning)
]
assert ultra == [], [str(w.message) for w in ultra]


def test_share_default_single_polar_emits_no_warnings(recwarn):
"""A single polar axis has nothing to share — must not warn at default share."""
fig, ax = uplt.subplots(proj="polar")
fig.canvas.draw()

ultra = [
w
for w in recwarn
if issubclass(w.category, uplt.internals.warnings.UltraPlotWarning)
]
assert ultra == [], [str(w.message) for w in ultra]


def test_share_default_single_polar_subplot_singular_emits_no_warnings(recwarn):
"""``uplt.subplot(proj='polar')`` (singular) has nothing to share either."""
fig, ax = uplt.subplot(proj="polar")
fig.canvas.draw()

ultra = [
w
for w in recwarn
if issubclass(w.category, uplt.internals.warnings.UltraPlotWarning)
]
assert ultra == [], [str(w.message) for w in ultra]


def test_auto_share_local_yscale_change_splits_group():
fig, axs = uplt.subplots(ncols=2, share="auto")
fig.canvas.draw()
Expand Down
Loading