From 1b8990313315c33bc9cc1edbf88b2b3b42d3bf02 Mon Sep 17 00:00:00 2001 From: djdt <10266332+djdt@users.noreply.github.com> Date: Fri, 5 Jun 2026 13:13:38 +0200 Subject: [PATCH] fix IndexError for x axis with stepMode="center" --- pyqtgraph/graphicsItems/PlotCurveItem.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/PlotCurveItem.py b/pyqtgraph/graphicsItems/PlotCurveItem.py index 1b687aa933..727c2df011 100644 --- a/pyqtgraph/graphicsItems/PlotCurveItem.py +++ b/pyqtgraph/graphicsItems/PlotCurveItem.py @@ -351,7 +351,10 @@ def dataBounds(self, ax, frac=1.0, orthoRange=None): if orthoRange is not None: mask = (d2 >= orthoRange[0]) * (d2 <= orthoRange[1]) if self.opts.get("stepMode", None) == "center": - mask = mask[:-1] # len(y) == len(x) - 1 when stepMode is center + if ax == 1: + mask = mask[:-1] # len(y) == len(x) - 1 when stepMode is center + else: + mask = np.concatenate([mask, [0]]) d = d[mask] #d2 = d2[mask]