8000 Merge pull request #10607 from anntzer/notify_axes_change · matplotlib/matplotlib@945ffa4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 945ffa4

Browse files
authored
Merge pull request #10607 from anntzer/notify_axes_change
Move notify_axes_change to FigureManagerBase class.
2 parents 4ac125e + 3df2055 commit 945ffa4

File tree

6 files changed

+10
-33
lines changed

6 files changed

+10
-33
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,15 @@ def __init__(self, canvas, num):
26212621
'key_press_event',
26222622
self.key_press)
26232623

2624+
self.toolmanager = None
2625+
self.toolbar = None
2626+
2627+
@self.canvas.figure.add_axobserver
2628+
def notify_axes_change(fig):
2629+
# Called whenever the current axes is changed.
2630+
if self.toolmanager is None and self.toolbar is not None:
2631+
self.toolbar.update()
2632+
26242633
def show(self):
26252634
"""
26262635
For GUI backends, show the figure window and redraw.

lib/matplotlib/backends/_backend_tk.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,6 @@ def __init__(self, canvas, num, window):
512512

513513
self._shown = False
514514

515-
def notify_axes_change(fig):
516-
'this will be called whenever the current axes is changed'
517-
if self.toolmanager is not None:
518-
pass
519-
elif self.toolbar is not None:
520-
self.toolbar.update()
521-
self.canvas.figure.add_axobserver(notify_axes_change)
522-
523515
def _get_toolbar(self):
524516
if matplotlib.rcParams['toolbar'] == 'toolbar2':
525517
toolbar = NavigationToolbar2Tk(self.canvas, self.window)

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,6 @@ def destroy(*args):
388388
self.window.show()
389389
self.canvas.draw_idle()
390390

391-
def notify_axes_change(fig):
392-
'this will be called whenever the current axes is changed'
393-
if self.toolmanager is not None:
394-
pass
395-
elif self.toolbar is not None:
396-
self.toolbar.update()
397-
self.canvas.figure.add_axobserver(notify_axes_change)
398-
399391
self.canvas.grab_focus()
400392

401393
def destroy(self, *args):

lib/matplotlib/backends/backend_macosx.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,13 @@ def __init__(self, canvas, num):
129129
FigureManagerBase.__init__(self, canvas, 8000 num)
130130
title = "Figure %d" % num
131131
_macosx.FigureManager.__init__(self, canvas, title)
132-
if rcParams['toolbar']=='toolbar2':
132+
if rcParams['toolbar'] == 'toolbar2':
133133
self.toolbar = NavigationToolbar2Mac(canvas)
134134
else:
135135
self.toolbar = None
136136
if self.toolbar is not None:
137137
self.toolbar.update()
138138

139-
def notify_axes_change(fig):
140-
'this will be called whenever the current axes is changed'
141-
if self.toolbar != None: self.toolbar.update()
142-
self.canvas.figure.add_axobserver(notify_axes_change)
143-
144139
if matplotlib.is_interactive():
145140
self.show()
146141
self.canvas.draw_idle()

lib/matplotlib/backends/backend_qt5.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,6 @@ def __init__(self, canvas, num):
616616
self.window.show()
617617
self.canvas.draw_idle()
618618

619-
def notify_axes_change(fig):
620-
# This will be called whenever the current axes is changed
621-
if self.toolbar is not None:
622-
self.toolbar.update()
623-
self.canvas.figure.add_axobserver(notify_axes_change)
624619
self.window.raise_()
625620

626621
def full_screen_toggle(self):

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,12 +1266,6 @@ def __init__(self, canvas, num, frame):
12661266
self.tb = frame.GetToolBar()
12671267
self.toolbar = self.tb # consistent with other backends
12681268

1269-
def notify_axes_change(fig):
1270-
'this will be called whenever the current axes is changed'
1271-
if self.tb is not None:
1272-
self.tb.update()
1273-
self.canvas.figure.add_axobserver(notify_axes_change)
1274-
12751269
def show(self):
12761270
self.frame.Show()
12771271
self.canvas.draw()

0 commit comments

Comments
 (0)
0