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

Skip to content

Commit cb3f9fd

Browse files
Skip sticky searching if empty
1 parent f188cd8 commit cb3f9fd

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
@@ -3089,13 +3089,16 @@ def handle_single_axis(
30893089
# streamplot; it is defined relative to x1-x0 but has
30903090
# no absolute term (e.g. "+1e-8") to avoid issues when working with
30913091
# datasets where all values are tiny (less than 1e-8).
3092-
tol = 1e-5 * abs(x1 - x0)
3093-
# Index of largest element < x0 + tol, if any.
3094-
i0 = stickies.searchsorted(x0 + tol) - 1
3095-
x0bound = stickies[i0] if i0 != -1 else None
3096-
# Index of smallest element > x1 - tol, if any.
3097-
i1 = stickies.searchsorted(x1 - tol)
3098-
x1bound = stickies[i1] if i1 != len(stickies) else None
3092+
if len(stickies):
3093+
tol = 1e-5 * abs(x1 - x0)
3094+
# Index of largest element < x0 + tol, if any.
3095+
i0 = stickies.searchsorted(x0 + tol) - 1
3096+
x0bound = stickies[i0] if i0 != -1 else None
3097+
# Index of smallest element > x1 - tol, if any.
3098+
i1 = stickies.searchsorted(x1 - tol)
3099+
x1bound = stickies[i1] if i1 != len(stickies) else None
3100+
else:
3101+
x0bound = x1bound = None
30993102

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

0 commit comments

Comments
 (0)