Skip to content

show(): title/aspect/frameon set once per render-command instead of once per panel #695

@timtreis

Description

@timtreis

Summary

In PlotAccessor.show, the per-panel title / aspect / frameon block runs once per render command instead of once per panel, because it sits inside the inner for cmd, params in render_cmds: loop.

Details

src/spatialdata_plot/pl/basic.py:1801-1813 is indented inside the inner render-command loop (which starts at ~basic.py:1687):

ax.set_title(t)
ax.set_aspect("equal")
ax.axis("off")
# ... title[i] length / IndexError check ...

So set_title / set_aspect("equal") / axis("off") execute for every render command on a panel (N× for an N-call chain), and the title[i] length validation re-runs each iteration — meaning an IndexError/length mismatch can surface mid-loop rather than up front.

This is harmless to current output (the calls are idempotent) but is redundant work and a fragile place for any future per-command side effect.

Suggested fix

Dedent the title/aspect/frameon block so it runs once after the inner loop (a natural home is a small _finalize_panel(ax, i, title, ...) helper). Validate len(title) == num_panels once, before the panel loop.


Found during a maintainability/refactor audit of main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions