◐ Shell
clean mode source ↗

FIX: fill contourf minimum region when it falls just below the lowest level (#21382) by SharadhNaidu · Pull Request #31903 · matplotlib/matplotlib

@SharadhNaidu

… level (matplotlib#21382)

contourf left the minimum-valued region unfilled when the data minimum
fell a floating-point hair below the lowest contour level instead of
being exactly equal to it (e.g. a computed -1.7e-13 where 0 was meant).
ContourSet._get_lowers_and_uppers only extended the lowest filled
interval down to the minimum when self.zmin == lowers[0] exactly, so
such near-equal minima, or rounding during automatic level selection,
slipped through and the region was clipped.

On a linear scale, compare the level against the data minimum with a
tolerance scaled to the data range rather than strict equality, the same
way Colorbar._add_solids does. The check is one-sided and tolerance-
bounded, so genuine gaps such as user-specified levels starting above
the data are left untouched, and every case the old equality test caught
still extends identically. Log scales span many decades where an additive
tolerance is not meaningful, so the exact-equality test is kept there
unchanged.

Adds check_figures_equal regression tests that a float-noise minimum
renders like a clean zero, including at very small and very large data
scales, plus guard tests that a user-specified lowest level above the
data is not back-filled, even when a large data range inflates the
tolerance to order unity. Includes a behaviour-change note under
doc/api/next_api_changes/.