Skip to content
Merged
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
2 changes: 2 additions & 0 deletions ultraplot/axes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3429,6 +3429,8 @@ def format(
return
if rc_mode == 1: # avoid resetting
return
if self._inset_parent is not None or self._panel_parent is not None:
return
self.figure.format(rc_kw=rc_kw, rc_mode=rc_mode, skip_axes=True, **params)

def draw(self, renderer=None, *args, **kwargs):
Expand Down
43 changes: 43 additions & 0 deletions ultraplot/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,46 @@ def test_alt_axes_x_shared():
assert alt.get_ylabel() == ""
axi.set_xlabel("X")
return fig


def test_inset_format_scope():
"""
Test that calling format() on an inset axes does not affect the
parent figure's properties like suptitle or super labels.
"""
fig, axs = uplt.subplots()
ax = axs[0]
# Inset axes are instances of the same class as the parent
ix = ax.inset_axes([0.5, 0.5, 0.4, 0.4])
assert ix._inset_parent is ax, "Inset parent should be the main axes"

# Test that suptitle is not set
ix.format(suptitle="This should not appear")
assert (
fig._suptitle is None or fig._suptitle.get_text() == ""
), "Inset format should not set the figure's suptitle."

# Test that leftlabels are not set
# Create a copy to ensure we're not comparing against a modified list
original_left_labels = list(fig._suplabel_dict["left"])
ix.format(leftlabels=["a", "b"])
assert (
list(fig._suplabel_dict["left"]) == original_left_labels
), "Inset format should not set the figure's leftlabels."


def test_panel_format_scope():
"""
Test that calling format() on a panel axes does not affect the
parent figure's properties like suptitle.
"""
fig, axs = uplt.subplots()
ax = axs[0]
pax = ax.panel_axes("right")
assert pax._panel_parent is ax, "Panel parent should be the main axes"

# Test that suptitle is not set
pax.format(suptitle="This should not appear")
assert (
fig._suptitle is None or fig._suptitle.get_text() == ""
), "Panel format should not set the figure's suptitle."