79458770

Date: 2025-02-21 22:43:07
Score: 1
Natty:
Report link

I did find a solution using a dummy case (and AI) Please see below for an example with five points (grid cells) to be plotted with pcolormesh. I missed the following:

from matplotlib.colors import ListedColormap, BoundaryNorm
...

bounds = np.arange(0.5, 6.5, 1)  # Boundaries between colors
norm = BoundaryNorm(bounds, cmap.N)
...

c = ax.pcolormesh(lon, lat, data, cmap=cmap, norm=norm, shading='auto')

It is necessary to define the bounds and norm.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Arty Trasher