Skip to content

fix: make plot_array overlays respect imshow_origin #565

Closed

Description

@Jammy2211

Overview

Development tracker for the reproducible community report now preserved as PyAutoLabs Discussion #14, originally PyAutoArray#535.

plot_array passes origin=origin_imshow to the image raster, but vector overlays (mask, border, origin, grid, mesh grid, positions, lines, and quiver coordinates) remain in unchanged data coordinates. With imshow_origin: lower, this silently mirrors the raster relative to its overlays.

The defect is still present on main as of 2026-09-21.

Acceptance

  • imshow_origin: upper retains current behaviour.
  • imshow_origin: lower keeps overlays registered to the corresponding image features.
  • Add a regression covering at least an asymmetric positions/lines overlay so a visually plausible but misregistered plot cannot silently recur.
  • Preserve the distinction between display orientation and PyAutoArray's internal y-coordinate convention.
  • Close this issue when the fix is merged, then mark the settling response in Discussion Get version number from env #14 as accepted.

Community context and reproducer: https://github.com/orgs/PyAutoLabs/discussions/14

Activity

  1. Jammy2211 commented on Oct 7, 2026

    @Jammy2211
    CollaboratorAuthor

    Plan (approved 2026-10-07, Claude CLI /community → /start_dev)

    Mind prompt: active/imshow_origin_lower_overlays.md. Branch feature/imshow-origin-lower-overlays.

    High-level

    • Add a helper in autoarray/plot/utils.py that reflects overlay y about the extent midpoint when imshow_origin == "lower" (Discussion Get version number from env #14 option 1, the pattern _apply_contours already uses). "upper" is unchanged.
    • Apply it in plot_array (autoarray/plot/array.py) to every overlay: mask edge, border, origin marker, grid, mesh grid, positions, lines, regions polygons, quiver (position and dy, which also flips sign). Patches are left as-is and documented as unsupported under "lower".
    • Audit plot/inversion.py and plot/grid.py for the same raster + overlay pairing and apply the helper wherever a raster carries the origin.
    • Add the Discussion's origin-agnostic regression test to test_autoarray/plot/, parametrised over both origins; confirmed red on unfixed main under "lower".
    • Document on the imshow_origin config key that it changes presentation only: under "lower" the displayed y axis and reported model y parameters disagree in sign.

    Detailed

    1. autoarray/plot/utils.py: _overlay_yx_for_origin(yx, extent, origin_imshow) — returns yx unchanged for "upper"; for "lower" returns a copy with yx[:, 0] = extent[2] + extent[3] - yx[:, 0]. None passes through. A sibling for quiver negates column 2 (dy) as well.
    2. autoarray/plot/array.py: after extent is resolved, wrap mask, border, origin, grid, mesh_grid, each positions entry, each lines entry, each regions polygon (pass through to plot_regions pre-reflected) and vector_yx through the helper before drawing. _apply_contours is untouched.
    3. plot/inversion.py lines ~159/170 and plot/grid.py ~128–174: apply only where the panel's raster is an imshow honouring origin_imshow; leave pure scatter panels alone.
    4. test_autoarray/plot/test_array.py (new): test__positions_marker_lands_on_block[upper|lower] per the Discussion's marker_lands_on_block; plus a lines variant. Config set via conf.instance["visualize"]["general"]["general"]["imshow_origin"] and restored in finally.
    5. autoarray/config/visualize/general.yaml comment on imshow_origin: presentation-only caveat.
    6. Run python -m pytest test_autoarray/plot/ test_autoarray/ ; downstream smoke not required (private helpers, no public API change).

    Tier: glance — merge mode: auto-merge on green if the Witness passes, post-merge summary.

    Community: reply on https://github.com/orgs/PyAutoLabs/discussions/14 after merge/release, crediting the reproducer and test.

  2. Jammy2211 commented on Oct 7, 2026

    @Jammy2211
    CollaboratorAuthor

    PR opened: #616 (branch feature/imshow-origin-lower-overlays, 93961c6). Fix covers plot_array and the uniform rectangular mesh path of plot_inversion_reconstruction; regression tests red on unfixed main for every lower case. Known out-of-scope quirk left for a follow-up: zoom_to_brightest in plot_inversion_reconstruction sets axis limits from an unreflected zoom extent, so under lower on a uniform mesh the zoom window can sit over the wrong part of the image.

  3. added a commit that references this issue on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions