Skip to content

Fix ImagePlot for data spanning the 180 degree meridian - #4233

Open
1915rising wants to merge 1 commit into
Unidata:mainfrom
1915rising:fix/1915-imageplot-full-globe-longitudes
Open

1915rising wants to merge 1 commit into
Unidata:mainfrom
1915rising:fix/1915-imageplot-full-globe-longitudes

Conversation

@1915rising

Copy link
Copy Markdown

Fixes #1915.

On a full [0, 360] longitude grid, ImagePlot.plotdata wrapped longitudes above 180 down by 360 without reordering, so the x coordinates came back [0, ..., 180, -179, ..., -1] — non-monotonic, with an imshow extent of (0, -1), and the image did not display.

The fix keeps the wrap, then, only when the wrapped coordinates are non-monotonic, sorts them and reorders the data columns with isel to match. Grids that do not cross the meridian take the exact previous path.

Tests: new regression test test_image_plot_plotdata_full_globe_longitudes (synthetic full-globe grid, longitude encoded in the data values so column alignment is checked) — fails before, passes after. Full tests/plots/test_declarative.py: 25 passed / 57 failed before, 26 passed / 57 failed after, with the failure set identical before and after; all 57 are pre-existing environment failures (cartopy Natural Earth downloads unavailable in my environment).

@1915rising
1915rising requested a review from a team as a code owner November 30, 2026 11:27
@1915rising
1915rising requested review from dopplershift and removed request for a team November 30, 2026 11:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImagePlot fails on some [0, 360] data

1 participant