Skip to content

Commit 79115c7

Browse files
committed
Fix ErrorBarCurveItem.get_closest_coordinates snap-to-bounds typo
The error-bar snapping logic in `get_closest_coordinates` compared `abs(y - y)` and `abs(x - x)` (always 0) instead of the distance to the current curve point `abs(y - yi)` / `abs(x - xi)`. As a result, the snap-to-error-bound branches were dead code and the closest coordinate returned was always the central curve point, never the upper/lower error bound — even when the cursor was clearly closest to a bar end. Replace the four self-subtractions with the correct distance to the sampled point so cursor queries snap to the nearest error-bar bound as documented.
1 parent 1376d00 commit 79115c7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

plotpy/items/curve/errorbar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ def get_closest_coordinates(self, x: float, y: float) -> tuple[float, float]:
221221
xi = self.dsamp(self._x)[i]
222222
yi = self.dsamp(self._y)[i]
223223
xmin, xmax, ymin, ymax = self.get_minmax_arrays()
224-
if abs(y - y) > abs(y - ymin[i]):
224+
if abs(y - yi) > abs(y - ymin[i]):
225225
yi = ymin[i]
226-
elif abs(y - y) > abs(y - ymax[i]):
226+
elif abs(y - yi) > abs(y - ymax[i]):
227227
yi = ymax[i]
228-
if abs(x - x) > abs(x - xmin[i]):
228+
if abs(x - xi) > abs(x - xmin[i]):
229229
xi = xmin[i]
230-
elif abs(x - x) > abs(x - xmax[i]):
230+
elif abs(x - xi) > abs(x - xmax[i]):
231231
xi = xmax[i]
232232
return xi, yi
233233

0 commit comments

Comments
 (0)