From 5908c6acabaee8af8c9374a59b7c1c87fd56a5b8 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 20 Jan 2026 14:29:13 +1000 Subject: [PATCH 1/2] Fix: Isolate inset and panel format from figure format --- ultraplot/axes/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ultraplot/axes/base.py b/ultraplot/axes/base.py index c4603c506..c260ecab9 100644 --- a/ultraplot/axes/base.py +++ b/ultraplot/axes/base.py @@ -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): From 9ae637de930ec7679722093804d1488ba81310cc Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 20 Jan 2026 15:07:41 +1000 Subject: [PATCH 2/2] Add smoke tests --- ultraplot/tests/test_axes.py | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ultraplot/tests/test_axes.py b/ultraplot/tests/test_axes.py index e59d5ac9f..f1fad637a 100644 --- a/ultraplot/tests/test_axes.py +++ b/ultraplot/tests/test_axes.py @@ -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."