@@ -3016,25 +3016,24 @@ def _nonrect(self, x):
3016
3016
3017
3017
def _tooltip_list (self , event , hover ):
3018
3018
import matplotlib .pyplot as plt
3019
- if event .xdata and event .ydata :
3020
- lines = plt .gca ().get_lines ()
3021
- num_of_points = 0
3019
+ lines = plt .gca ().get_lines ()
3020
+ num_of_points = 0
3021
+ for line in lines :
3022
+ num_of_points += 1
3023
+ if num_of_points >= len (hover ):
3024
+ raise ValueError ("""Number of data points
3025
+ does not match up with number of labels""" )
3026
+ else :
3027
+ mouse_x = event .xdata
3028
+ mouse_y = event .ydata
3022
3029
for line in lines :
3023
- num_of_points += 1
3024
- if num_of_points >= len (hover ):
3025
- raise ValueError ("""Number of data points
3026
- does not match up with number of labels""" )
3027
- else :
3028
- mouse_x = event .xdata
3029
- mouse_y = event .ydata
3030
- for line in lines :
3031
- x_data = line .get_xdata ()
3032
- y_data = line .get_ydata ()
3033
- for i in range (len (x_data )):
3034
- distance = ((event .xdata - x_data [i ])** 2
3035
- + (event .ydata - y_data [i ])** 2 )** 0.5
3036
- if distance < 0.05 :
3037
- return "Data Label: " + hover [i ]
3030
+ x_data = line .get_xdata ()
3031
+ y_data = line .get_ydata ()
3032
+ for i in range (len (x_data )):
3033
+ distance = ((event .xdata - x_data [i ])** 2
3034
+ + (event .ydata - y_data [i ])** 2 )** 0.5
3035
+ if distance < 0.05 :
3036
+ return "Data Label: " + hover [i ]
3038
3037
3039
3038
def mouse_move (self , event ):
3040
3039
self ._update_cursor (event )
0 commit comments