Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02fb7e0

Browse filesBrowse files
committed
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.
1 parent 546b9fc commit 02fb7e0
Copy full SHA for 02fb7e0

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed

‎examples/event_handling/cursor_demo.py

Copy file name to clipboardExpand all lines: examples/event_handling/cursor_demo.py
+6-6Lines changed: 6 additions & 6 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.