Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6a1d31

Browse files
author
root
committed
initial style fixes
1 parent 82a2ab3 commit d6a1d31

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,13 +3031,12 @@ def mouse_move(self, event):
30313031
))
30323032
elif type(hover) == list:
30333033
import matplotlib.pyplot as plt
3034-
#get number of data points first
30353034
lines = plt.gca().get_lines()
3036-
num_of_points =0
3035+
num_of_points = 0
30373036
for line in lines:
3038-
num_of_points+=1
3037+
num_of_points += 1
30393038
if num_of_points >= len(hover):
3040-
raise ValueError("""Number of data points
3039+
raise ValueError("""Number of data points
30413040
does not match up woth number of labels""")
30423041
else:
30433042
mouse_x = event.xdata
@@ -3046,17 +3045,12 @@ def mouse_move(self, event):
30463045
x_data = line.get_xdata()
30473046
y_data = line.get_ydata()
30483047
for i in range(len(x_data)):
3049-
# calculate distance between cursor position and data point
3050-
distance = ((event.xdata - x_data[i])**2 + (event.ydata - y_data[i])**2)**0.5
3051-
if distance < 0.05: # modify this threshold as needed
3048+
distance = ((event.xdata - x_data[i])**2
3049+
+ (event.ydata - y_data[i])**2)**0.5
3050+
if distance < 0.05:
30523051
(self.set_hover_message("Data Label: "+ hover[i] +
30533052
" Original coords: "
30543053
))
3055-
3056-
3057-
3058-
3059-
30603054
else:
30613055
self.set_hover_message(self._mouse_event_to_message(event))
30623056
else:

lib/matplotlib/tests/test_toolkit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ def user_defined_function(event):
3333
# plt.ylabel('some numbers')
3434

3535
# ax.plot(rand(3), 'o', hover=['London','Paris','Barcelona'])
36-
# plt.show()
36+
# plt.show()

0 commit comments

Comments
 (0)