Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit0da7d89

Browse files
authored
Merge pull request#28582 from rcomer/sticky-contour
FIX: make sticky edge tolerance relative to data range
2 parents6a32a6f +9bd176d commit0da7d89

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,22 +2962,16 @@ def handle_single_axis(
29622962

29632963
# Prevent margin addition from crossing a sticky value. A small
29642964
# tolerance must be added due to floating point issues with
2965-
# streamplot; it is defined relative tox0, x1,x1-x0 but has
2965+
# streamplot; it is defined relative to 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]ifi0!=-1elseNone
2972-
# Ensure the boundary acts only if the sticky is the extreme value
2973-
ifx0boundisnotNoneandx0bound>x0:
2974-
x0bound=None
29752972
# Index of smallest element > x1 - tol, if any.
29762973
i1=stickies.searchsorted(x1-tol)
29772974
x1bound=stickies[i1]ifi1!=len(stickies)elseNone
2978-
# Ensure the boundary acts only if the sticky is the extreme value
2979-
ifx1boundisnotNoneandx1bound<x1:
2980-
x1bound=None
29812975

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

‎lib/matplotlib/tests/test_axes.py

Lines 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+
deftest_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
deftest_nargs_stem():
705715
withpytest.raises(TypeError,match='0 were given'):
706716
# stem() takes 1-3 arguments.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp