From 16aec15da2e3f0e5437bc50f4d5938ce40523fcf Mon Sep 17 00:00:00 2001 From: anon Date: Sun, 7 Jun 2026 05:49:03 +0200 Subject: [PATCH] Set panel title/aspect/frameon once per panel, not per render command (#695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `show()`, the title/`set_aspect`/`axis("off")` block sat inside the `for cmd, params in render_cmds:` loop, so for a chained call (e.g. render_images().render_shapes()) these ran once per render command instead of once per panel, and the title-length `IndexError` check re-evaluated each iteration (so it could surface mid-loop rather than up front). Dedent the block one level so it runs once per panel after the per-command loop. Output is unchanged (the calls are idempotent) — verified byte-identical to main for single- and multi-command chains with title and frameon set. --- src/spatialdata_plot/pl/basic.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/spatialdata_plot/pl/basic.py b/src/spatialdata_plot/pl/basic.py index f864482c..f837fe4c 100644 --- a/src/spatialdata_plot/pl/basic.py +++ b/src/spatialdata_plot/pl/basic.py @@ -1794,19 +1794,21 @@ def _draw_colorbar( colorbar_requests=axis_colorbar_requests, ) - if title is None: - t = panel_key if panel_key is not None else cs - elif len(title) == 1: - t = title[0] - else: - try: - t = title[i] - except IndexError as e: - raise IndexError("The number of titles must match the number of panels.") from e - ax.set_title(t) - ax.set_aspect("equal") - if fig_params.frameon is False: - ax.axis("off") + # Title/aspect/frameon are panel-level: set once per panel, after the + # per-command loop above (not once per render command). + if title is None: + t = panel_key if panel_key is not None else cs + elif len(title) == 1: + t = title[0] + else: + try: + t = title[i] + except IndexError as e: + raise IndexError("The number of titles must match the number of panels.") from e + ax.set_title(t) + ax.set_aspect("equal") + if fig_params.frameon is False: + ax.axis("off") if has_shapes and wants_shapes: empty_shape_elements = [