8000 Fix cursor_demo wrt. Line2D.set_x/ydata not accepting scalars anymore. · matplotlib/matplotlib@6a3209c · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a3209c

Browse files
anntzerksunden
authored andcommitted
Fix cursor_demo wrt. Line2D.set_x/ydata not accepting scalars anymore.
Trying to run the example prior to the PR would result in exceptions being thrown on mouse moves. Manual backport of #25106 rolled into backport of #25129 (backport pr #25160)
1 parent 99a2c5f commit 6a3209c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/event_handling/cursor_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def on_mouse_move(self, event):
5858
self.set_cross_hair_visible(True)
5959
x, y = event.xdata, event.ydata
6060
# update the line positions
61-
self.horizontal_line.set_ydata(y)
62-
self.vertical_line.set_xdata(x)
61+
self.horizontal_line.set_ydata([y])
62+
self.vertical_line.set_xdata([x])
6363
self.text.set_text('x=%1.2f, y=%1.2f' % (x, y))
6464
self.ax.figure.canvas.draw()
6565

@@ -140,8 +140,8 @@ def on_mouse_move(self, event):
140140
self.set_cross_hair_visible(True)
141141
# update the line positions
142142
x, y = event.xdata, event.ydata
143-
self.horizontal_line.set_ydata(y)
144-
self.vertical_line.set_xdata(x)
143+
self.horizontal_line.set_ydata([y])
144+
self.vertical_line.set_xdata([x])
145145
self.text.set_text('x=%1.2f, y=%1.2f' % (x, y))
146146

147147
self.ax.figure.canvas.restore_region(self.background)
@@ -218,8 +218,8 @@ def on_mouse_move(self, event):
218218
x = self.x[index]
219219
y = self.y[index]
220220
# update the line positions
221-
self.horizontal_line.set_ydata(y)
222-
self.vertical_line.set_xdata(x)
221+
self.horizontal_line.set_ydata([y])
222+
self.vertical_line.set_xdata([x])
223223
self.text.set_text('x=%1.2f, y=%1.2f' % (x, y))
224224
self.ax.figure.canvas.draw()
225225

0 commit comments

Comments
 (0)
0