Skip to content

fix: use last/first colour for over/under when extend=None - #244

Open
mercael91 wants to merge 7 commits into
ecmwf:mainfrom
mercael91:fix/contour-final-level-color
Open

fix: use last/first colour for over/under when extend=None#244
mercael91 wants to merge 7 commits into
ecmwf:mainfrom
mercael91:fix/contour-final-level-color

Conversation

@mercael91

Copy link
Copy Markdown

Summary

When extend_levels=False and extend=None, the over and under colours were set to transparent (0, 0, 0, 0). This caused a value exactly equal to levels[-1] to render transparent instead of using the last colour in the map.

Matplotlib's default Colormap behaviour is to fall back to the last colour for the over-range. This PR aligns earthkit-plots with that by defaulting over_color to colors[-1] and under_color to colors[0].

Change

# Before
over_color = (0, 0, 0, 0)
under_color = (0, 0, 0, 0)

# After
over_color = colors[-1]  # Use last colour as over-color
under_color = colors[0]  # Use first colour as under-color

Verification

  • A value equal to levels[-1] now renders with the last colour instead of transparent
  • A value equal to levels[0] continues to render with the first colour
  • Behaviour with extend="both", extend="max", extend="min" is unchanged

Fixes #243

JamesVarndell and others added 7 commits July 13, 2026 12:00
…ections (ecmwf#232)

* Adds transform_first='auto' option

* Adds image test to ensure regridding on non-cylindrical projections works

* Updates regridding docs to use pcolormesh, to show the regridding process more visibly
* Tweaks to default zorders

* Undo log level changes; committed to wrong branch

* Increase zorders to be 2 by default
* Handle ListedColormaps in expand and cmap_and_norm

* Copy definition of colors from expand to cmap_and_norm
When  and , the over and under
colours were set to transparent . This caused a value
exactly equal to  to render transparent instead of using
the last colour in the map.

Matplotlib's default  behaviour is to fall back to the
last colour for the over-range. Align earthkit-plots with that by
defaulting  to  and  to
.

Fixes ecmwf#243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants