From a067fc4918ca4d300278a2d0552251a27dd926bf Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Thu, 13 Jun 2024 17:42:43 -0500 Subject: [PATCH] Make sticky edges only apply if the sticky edge is the most extream limit point --- lib/matplotlib/axes/_base.py | 6 ++++++ .../test_axes/sticky_tolerance.png | Bin 0 -> 3941 bytes lib/matplotlib/tests/test_axes.py | 19 ++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 lib/matplotlib/tests/baseline_images/test_axes/sticky_tolerance.png diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 1cf56c90cc6c..b810501ec7bb 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2942,9 +2942,15 @@ def handle_single_axis( # Index of largest element < x0 + tol, if any. i0 = stickies.searchsorted(x0 + tol) - 1 x0bound = stickies[i0] if i0 != -1 else None + # Ensure the boundary acts only if the sticky is the extreme value + if x0bound is not None and x0bound > x0: + x0bound = None # Index of smallest element > x1 - tol, if any. i1 = stickies.searchsorted(x1 - tol) x1bound = stickies[i1] if i1 != len(stickies) else None + # Ensure the boundary acts only if the sticky is the extreme value + if x1bound is not None and x1bound < x1: + x1bound = None # Add the margin in figure space and then transform back, to handle # non-linear scales. diff --git a/lib/matplotlib/tests/baseline_images/test_axes/sticky_tolerance.png b/lib/matplotlib/tests/baseline_images/test_axes/sticky_tolerance.png new file mode 100644 index 0000000000000000000000000000000000000000..a3fb13d0716aed8de5596a838828e103d7b23d5d GIT binary patch literal 3941 zcmd^?Yfw{X8pq#+G@?b&I#o(BI3jfwxf2@-0W7v44B*0c!GwDWS4kp-01-&oZNV*< z>^dwgh6R}&p=y&N8W2M+6*Wpk>Sj%(5E9BIg-8g5G$0A=LEEm~wS3W;b!R`EIWzB^ z_ni0nKhN{~Kj#leBZ4n=kKJ=Ty z#u>#SqNDuH^83N>i!9)$2)$m12&u5aVC2YA%(Uzjzs0J9c|b&lH4c8azb0#Un(9yd341y}2||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ET@m})sxi7)X@rcUWAM0L1hSzubAP;CVLJJ>mNC>(t2hx3VXox|hHSs}RKInP zpnuc6M52?h*Xc`hQX6(KBZI!AV|H-pS=jP;PzIUuD>=7Latt8Mb0Duly|h3((^@VC zVaZSl-P)*n3nJ~*H7&(ZqNMFff<3ZU$t*=)$Ge6+YsRMR%3BN}BKX6dBKDl+q7_#b zm7Rk{w!2d|kh5RGQ2)Y{S?qb57eKrn(7b{>$O_kZFam#xkc%#=*CAjd>Nk>3}3i5)eP-q~Y+w;enHDA!+m~%HvSC-UKpDAE$mz;v0a}PXx z=xz%pQ{4B5}UkFyCYznA7K!iRhD6lY~(SD(2^Q9r_Rg0|H*@PC@JZ7;}h{>6(&A(ss9_R;pw z=Fwf%D8W7cQi*mzGtAQeS1shF^Yb}ww+inL6?=JNOwQ0xEjaQ)#9_|+Nx%Ci*GT0M literal 0 HcmV?d00001 diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index dd37d3d8ee80..48121ee04939 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -682,6 +682,25 @@ def test_sticky_shared_axes(fig_test, fig_ref): ax0.pcolormesh(Z) +@image_comparison(['sticky_tolerance.png'], remove_text=True, style="mpl20") +def test_sticky_tolerance(): + fig, axs = plt.subplots(2, 2) + + width = .1 + + axs.flat[0].bar(x=0, height=width, bottom=20000.6) + axs.flat[0].bar(x=1, height=width, bottom=20000.1) + + axs.flat[1].bar(x=0, height=-width, bottom=20000.6) + axs.flat[1].bar(x=1, height=-width, bottom=20000.1) + + axs.flat[2].barh(y=0, width=-width, left=-20000.6) + axs.flat[2].barh(y=1, width=-width, left=-20000.1) + + axs.flat[3].barh(y=0, width=width, left=-20000.6) + axs.flat[3].barh(y=1, width=width, left=-20000.1) + + def test_nargs_stem(): with pytest.raises(TypeError, match='0 were given'): # stem() takes 1-3 arguments. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy