Skip to content

Commit 6557e30

Browse files
committed
Set panel title/aspect/frameon once per panel, not per render command (#695)
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.
1 parent b370b1f commit 6557e30

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

‎src/spatialdata_plot/pl/basic.py‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,19 +1794,21 @@ def _draw_colorbar(
17941794
colorbar_requests=axis_colorbar_requests,
17951795
)
17961796

1797-
if title is None:
1798-
t = panel_key if panel_key is not None else cs
1799-
elif len(title) == 1:
1800-
t = title[0]
1801-
else:
1802-
try:
1803-
t = title[i]
1804-
except IndexError as e:
1805-
raise IndexError("The number of titles must match the number of panels.") from e
1806-
ax.set_title(t)
1807-
ax.set_aspect("equal")
1808-
if fig_params.frameon is False:
1809-
ax.axis("off")
1797+
# Title/aspect/frameon are panel-level: set once per panel, after the
1798+
# per-command loop above (not once per render command).
1799+
if title is None:
1800+
t = panel_key if panel_key is not None else cs
1801+
elif len(title) == 1:
1802+
t = title[0]
1803+
else:
1804+
try:
1805+
t = title[i]
1806+
except IndexError as e:
1807+
raise IndexError("The number of titles must match the number of panels.") from e
1808+
ax.set_title(t)
1809+
ax.set_aspect("equal")
1810+
if fig_params.frameon is False:
1811+
ax.axis("off")
18101812

18111813
if has_shapes and wants_shapes:
18121814
empty_shape_elements = [

0 commit comments

Comments
 (0)