Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 69d54ad

Browse filesBrowse files
committed
FIX: make sticky edge tolerance relative to data range
1 parent 9b8a8c7 commit 69d54ad
Copy full SHA for 69d54ad

File tree

3 files changed

+11
-7
lines changed
Filter options

3 files changed

+11
-7
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,19 +2965,13 @@ def handle_single_axis(
29652965
# streamplot; it is defined relative to x0, x1, x1-x0 but has
29662966
# no absolute term (e.g. "+1e-8") to avoid issues when working with
29672967
# datasets where all values are tiny (less than 1e-8).
2968-
tol = 1e-5 * max(abs(x0), abs(x1), abs(x1 - x0))
2968+
tol = 1e-5 * abs(x1 - x0)
29692969
# Index of largest element < x0 + tol, if any.
29702970
i0 = stickies.searchsorted(x0 + tol) - 1
29712971
x0bound = stickies[i0] if i0 != -1 else None
2972-
# Ensure the boundary acts only if the sticky is the extreme value
2973-
if x0bound is not None and x0bound > x0:
2974-
x0bound = None
29752972
# Index of smallest element > x1 - tol, if any.
29762973
i1 = stickies.searchsorted(x1 - tol)
29772974
x1bound = stickies[i1] if i1 != len(stickies) else None
2978-
# Ensure the boundary acts only if the sticky is the extreme value
2979-
if x1bound is not None and x1bound < x1:
2980-
x1bound = None
29812975

29822976
# Add the margin in figure space and then transform back, to handle
29832977
# non-linear scales.
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,16 @@ def test_sticky_tolerance():
701701
axs.flat[3].barh(y=1, width=width, left=-20000.1)
702702

703703

704+
@image_comparison(['sticky_tolerance_cf.png'], remove_text=True, style="mpl20")
705+
def test_sticky_tolerance_contourf():
706+
fig, ax = plt.subplots()
707+
708+
x = y = [14496.71, 14496.75]
709+
data = [[0, 1], [2, 3]]
710+
711+
ax.contourf(x, y, data)
712+
713+
704714
def test_nargs_stem():
705715
with pytest.raises(TypeError, match='0 were given'):
706716
# stem() takes 1-3 arguments.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.