plt.pcolormesh will infer interval breaks per default
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Looking at some warnings in #3266 I saw that matplotlib will deprecate the old behaviour of pcolormesh when the shape of the data and the coordinates are equal (they silently cut a row and a column of the data). With the new behaviour they will interpolate the coordinates.
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3])
y = np.array([1, 2, 3, 4, 5])
data = np.random.randn(*y.shape + x.shape)
f, axes = plt.subplots(1, 2)
for ax, shading, behavior in zip(axes, ["flat", "nearest"], ["old", "new"]):
ax.pcolormesh(x, y, data, shading=shading, vmin=-0.75, vmax=0.75)
ax.set_title(f"{behavior}: shading='{shading}'")

This is a good thing in general - we already do this for a long time with the infer_intervals keyword. Unfortunately they don't check if the data is monotonic (matplotlib/matplotlib#18317) which can lead to problems for maps (scitools/cartopy#1638). I don't think there is a need to do something right now - let's see what they think upstream.
This change was introduced in mpl 3.3.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the pcolormesh behavior introduced in matplotlib 3.3.0 and the upstream discussion in matplotlib/matplotlib#18317. Compare that behavior with xarray's existing infer_intervals handling and the map-related concern in scitools/cartopy#1638; the issue does not name a file, test, or specific change, so completion depends on deciding what upstream behavior xarray should support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, numpy, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100