#26220·matplotlib

[ENH]: errorbar(x, y, yrange=...) as an alternative to errorbar(x, y, yerr=...)

Author: timhoffmCreated Jun 29, 2023Updated Sep 30, 2026
LabelsNew featurekeep

Problem

Inspired from #26187:

It is sometimes easier to pass the explicit error range rather than +/- values from a given point.

Proposed solution

The suggestion is to support a yrange parameter so that one can do either:

errorbar(x, y, yerr=...)
errorbar(x, y, yrange=...)

Passing both parameters should result in an error.

Having mutually exclusive yerr, yrange parameters is usually a code smell. However here, it may actually be a viable option. (Practiality beats purity).

Is this really necessary? The user could just calculate yerr from their range values.

I think the shortest way to calculate this would be:

ymin = yrange[:,0]
ymax = yrange[:,1]
yerr = np.array([y - ymin, ymax - y]).T

This is quite tedious to get right (in particular the sign for the neg. yerr). Additionally, this still does not cover unit handling. So I assume, the yrange parameter would be a substantial simplification.