@@ -813,7 +813,10 @@ def _update_val_from_pos(self, pos):
813813val = self ._max_in_bounds (pos )
814814self .set_max (val )
815815if self ._active_handle :
816- self ._active_handle .set_xdata ([val ])
816+ if self .orientation == "vertical" :
817+ self ._active_handle .set_ydata ([val ])
818+ else :
819+ self ._active_handle .set_xdata ([val ])
817820
818821def _update (self ,event ):
819822"""Update the slider position."""
@@ -835,12 +838,19 @@ def _update(self, event):
835838self ._active_handle = None
836839return
837840
838- # determine which handle was grabbed
839- handle = self ._handles [
840- np .argmin (
841+ if self .orientation == "vertical" :
842+ # determine which handle was grabbed
843+ event_handle = np .argmin (
844+ np .abs ([h .get_ydata ()[0 ]- event .ydata for h in self ._handles ])
845+ )
846+ handle = self ._handles [event_handle ]
847+ else :
848+ # determine which handle was grabbed
849+ event_handle = np .argmin (
841850np .abs ([h .get_xdata ()[0 ]- event .xdata for h in self ._handles ])
842851 )
843- ]
852+ handle = self ._handles [event_handle ]
853+
844854# these checks ensure smooth behavior if the handles swap which one
845855# has a higher value. i.e. if one is dragged over and past the other.
846856if handle is not self ._active_handle :
@@ -904,14 +914,22 @@ def set_val(self, val):
904914xy [2 ]= .75 ,val [1 ]
905915xy [3 ]= .75 ,val [0 ]
906916xy [4 ]= .25 ,val [0 ]
917+
918+ self ._handles [0 ].set_ydata ([val [0 ]])
919+ self ._handles [1 ].set_ydata ([val [1 ]])
907920else :
908921xy [0 ]= val [0 ],.25
909922xy [1 ]= val [0 ],.75
910923xy [2 ]= val [1 ],.75
911924xy [3 ]= val [1 ],.25
912925xy [4 ]= val [0 ],.25
926+
927+ self ._handles [0 ].set_xdata ([val [0 ]])
928+ self ._handles [1 ].set_xdata ([val [1 ]])
929+
913930self .poly .xy = xy
914931self .valtext .set_text (self ._format (val ))
932+
915933if self .drawon :
916934self .ax .figure .canvas .draw_idle ()
917935self .val = val