From 02fb7e0383a2e277cf965f8e14d206aadf167ebf Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 29 Jan 2023 19:52:04 +0100 Subject: [PATCH] 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. --- examples/event_handling/cursor_demo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/event_handling/cursor_demo.py b/examples/event_handling/cursor_demo.py index 3b4f2a05f82b..96dacee09004 100644 --- a/examples/event_handling/cursor_demo.py +++ b/examples/event_handling/cursor_demo.py @@ -56,8 +56,8 @@ def on_mouse_move(self, event): self.set_cross_hair_visible(True) x, y = event.xdata, event.ydata # update the line positions - self.horizontal_line.set_ydata(y) - self.vertical_line.set_xdata(x) + self.horizontal_line.set_ydata([y]) + self.vertical_line.set_xdata([x]) self.text.set_text(f'x={x:1.2f}, y={y:1.2f}') self.ax.figure.canvas.draw() @@ -132,8 +132,8 @@ def on_mouse_move(self, event): self.set_cross_hair_visible(True) # update the line positions x, y = event.xdata, event.ydata - self.horizontal_line.set_ydata(y) - self.vertical_line.set_xdata(x) + self.horizontal_line.set_ydata([y]) + self.vertical_line.set_xdata([x]) self.text.set_text(f'x={x:1.2f}, y={y:1.2f}') self.ax.figure.canvas.restore_region(self.background) @@ -204,8 +204,8 @@ def on_mouse_move(self, event): x = self.x[index] y = self.y[index] # update the line positions - self.horizontal_line.set_ydata(y) - self.vertical_line.set_xdata(x) + self.horizontal_line.set_ydata([y]) + self.vertical_line.set_xdata([x]) self.text.set_text(f'x={x:1.2f}, y={y:1.2f}') self.ax.figure.canvas.draw() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy