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 314ae4c

Browse filesBrowse files
committed
Clip slider init marker to slider track.
This avoids pixelization-related asymmetries, e.g. with the subplot params tool. I'm not sure why self.track needs to be wrapped in a TransformedPatchPath (clip_path seems supposed to also directly support rectangles), but in any case this works...
1 parent 79b3232 commit 314ae4c
Copy full SHA for 314ae4c

File tree

1 file changed

+7
-7
lines changed
Filter options

1 file changed

+7
-7
lines changed

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from . import _api, backend_tools, cbook, colors, ticker
2121
from .lines import Line2D
2222
from .patches import Circle, Rectangle, Ellipse
23+
from .transforms import TransformedPatchPath
2324

2425

2526
class LockDraw:
@@ -439,7 +440,10 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
439440
)
440441
ax.add_patch(self.track)
441442
self.poly = ax.axhspan(valmin, valinit, .25, .75, **kwargs)
442-
self.hline = ax.axhline(valinit, .15, .85, color=initcolor, lw=1)
443+
# Drawing a longer line and clipping it to the track avoids
444+
# pixellization-related asymmetries.
445+
self.hline = ax.axhline(valinit, 0, 1, color=initcolor, lw=1,
446+
clip_path=TransformedPatchPath(self.track))
443447
handleXY = [[0.5], [valinit]]
444448
else:
445449
self.track = Rectangle(
@@ -449,12 +453,8 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
449453
)
450454
ax.add_patch(self.track)
451455
self.poly = ax.axvspan(valmin, valinit, .25, .75, **kwargs)
452-
# These asymmetric limits (.2, .9) minimize the asymmetry
453-
# above and below the *poly* when rendered to pixels.
454-
# This seems to be different for Horizontal and Vertical lines.
455-
# For discussion see:
456-
# https://github.com/matplotlib/matplotlib/pull/19265
457-
self.vline = ax.axvline(valinit, .2, .9, color=initcolor, lw=1)
456+
self.vline = ax.axvline(valinit, 0, 1, color=initcolor, lw=1,
457+
clip_path=TransformedPatchPath(self.track))
458458
handleXY = [[valinit], [0.5]]
459459
self._handle, = ax.plot(
460460
*handleXY,

0 commit comments

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