Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ac6386

Browse files
Skip sticky searching if empty
1 parent 537a209 commit 6ac6386

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,13 +3073,16 @@ def handle_single_axis(
30733073
# streamplot; it is defined relative to x1-x0 but has
30743074
# no absolute term (e.g. "+1e-8") to avoid issues when working with
30753075
# datasets where all values are tiny (less than 1e-8).
3076-
tol = 1e-5 * abs(x1 - x0)
3077-
# Index of largest element < x0 + tol, if any.
3078-
i0 = stickies.searchsorted(x0 + tol) - 1
3079-
x0bound = stickies[i0] if i0 != -1 else None
3080-
# Index of smallest element > x1 - tol, if any.
3081-
i1 = stickies.searchsorted(x1 - tol)
3082-
x1bound = stickies[i1] if i1 != len(stickies) else None
3076+
if len(stickies):
3077+
tol = 1e-5 * abs(x1 - x0)
3078+
# Index of largest element < x0 + tol, if any.
3079+
i0 = stickies.searchsorted(x0 + tol) - 1
3080+
x0bound = stickies[i0] if i0 != -1 else None
3081+
# Index of smallest element > x1 - tol, if any.
3082+
i1 = stickies.searchsorted(x1 - tol)
3083+
x1bound = stickies[i1] if i1 != len(stickies) else None
3084+
else:
3085+
x0bound = x1bound = None
30833086

30843087
# Add the margin in figure space and then transform back, to handle
30853088
# non-linear scales.

0 commit comments

Comments
 (0)