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

Skip to content

Inline Cursor._update into its sole caller. #26946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1886,23 +1886,19 @@ def onmove(self, event):
if not self.ax.contains(event)[0]:
self.linev.set_visible(False)
self.lineh.set_visible(False)

if self.needclear:
self.canvas.draw()
self.needclear = False
return
self.needclear = True

xdata, ydata = self._get_data_coords(event)
self.linev.set_xdata((xdata, xdata))
self.linev.set_visible(self.visible and self.vertOn)
self.lineh.set_ydata((ydata, ydata))
self.lineh.set_visible(self.visible and self.horizOn)

if self.visible and (self.vertOn or self.horizOn):
self._update()

def _update(self):
if not (self.visible and (self.vertOn or self.horizOn)):
return
# Redraw.
if self.useblit:
if self.background is not None:
self.canvas.restore_region(self.background)
Expand All @@ -1911,7 +1907,6 @@ def _update(self):
self.canvas.blit(self.ax.bbox)
else:
self.canvas.draw_idle()
return False


class MultiCursor(Widget):
Expand Down Expand Up @@ -2026,10 +2021,9 @@ def onmove(self, event):
for line in self.hlines:
line.set_ydata((ydata, ydata))
line.set_visible(self.visible and self.horizOn)
if self.visible and (self.vertOn or self.horizOn):
self._update()

def _update(self):
if not (self.visible and (self.vertOn or self.horizOn)):
return
# Redraw.
if self.useblit:
for canvas, info in self._canvas_infos.items():
if info["background"]:
Expand Down