Skip to content

Commit f10d0d1

Browse files
authored
Merge pull request #25106 from anntzer/cd
Fix cursor_demo wrt. Line2D.set_x/ydata not accepting scalars anymore.
2 parents 546b9fc + 02fb7e0 commit f10d0d1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/event_handling/cursor_demo.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def on_mouse_move(self, event):
5656
self.set_cross_hair_visible(True)
5757
x, y = event.xdata, event.ydata
5858
# update the line positions
59-
self.horizontal_line.set_ydata(y)
60-
self.vertical_line.set_xdata(x)
59+
self.horizontal_line.set_ydata([y])
60+
self.vertical_line.set_xdata([x])
6161
self.text.set_text(f'x={x:1.2f}, y={y:1.2f}')
6262
self.ax.figure.canvas.draw()
6363

@@ -132,8 +132,8 @@ def on_mouse_move(self, event):
132132
self.set_cross_hair_visible(True)
133133
# update the line positions
134134
x, y = event.xdata, event.ydata
135-
self.horizontal_line.set_ydata(y)
136-
self.vertical_line.set_xdata(x)
135+
self.horizontal_line.set_ydata([y])
136+
self.vertical_line.set_xdata([x])
137137
self.text.set_text(f'x={x:1.2f}, y={y:1.2f}')
138138

139139
self.ax.figure.canvas.restore_region(self.background)
@@ -204,8 +204,8 @@ def on_mouse_move(self, event):
204204
x = self.x[index]
205205
y = self.y[index]
206206
# update the line positions
207-
self.horizontal_line.set_ydata(y)
208-
self.vertical_line.set_xdata(x)
207+
self.horizontal_line.set_ydata([y])
208+
self.vertical_line.set_xdata([x])
209209
self.text.set_text(f'x={x:1.2f}, y={y:1.2f}')
210210
self.ax.figure.canvas.draw()
211211

0 commit comments

Comments
 (0)