diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 2579efc0e191..c9637bbc615d 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -20,6 +20,7 @@ from . import _api, backend_tools, cbook, colors, ticker from .lines import Line2D from .patches import Circle, Rectangle, Ellipse +from .transforms import TransformedPatchPath class LockDraw: @@ -439,7 +440,10 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None, ) ax.add_patch(self.track) self.poly = ax.axhspan(valmin, valinit, .25, .75, **kwargs) - self.hline = ax.axhline(valinit, .15, .85, color=initcolor, lw=1) + # Drawing a longer line and clipping it to the track avoids + # pixellization-related asymmetries. + self.hline = ax.axhline(valinit, 0, 1, color=initcolor, lw=1, + clip_path=TransformedPatchPath(self.track)) handleXY = [[0.5], [valinit]] else: self.track = Rectangle( @@ -449,12 +453,8 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None, ) ax.add_patch(self.track) self.poly = ax.axvspan(valmin, valinit, .25, .75, **kwargs) - # These asymmetric limits (.2, .9) minimize the asymmetry - # above and below the *poly* when rendered to pixels. - # This seems to be different for Horizontal and Vertical lines. - # For discussion see: - # https://github.com/matplotlib/matplotlib/pull/19265 - self.vline = ax.axvline(valinit, .2, .9, color=initcolor, lw=1) + self.vline = ax.axvline(valinit, 0, 1, color=initcolor, lw=1, + clip_path=TransformedPatchPath(self.track)) handleXY = [[valinit], [0.5]] self._handle, = ax.plot( *handleXY,
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: