8000 Register figureoptions edits in views history. · matplotlib/matplotlib@ebb2c01 · GitHub
[go: up one dir, main page]

Skip to content

Commit ebb2c01

Browse files
committed
Register figureoptions edits in views history.
Changing axes limits in views history is now taken into account by the views history navigation. The home position is now defined the first time the figure canvas is drawn (rather than the first time an edit button is selected), via a one-shot callback.
1 parent af77c85 commit ebb2c01

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import six
4040
from six.moves import xrange
4141

42+
from functools import partial
4243
import os
4344
import sys
4445
import warnings
@@ -2763,6 +2764,13 @@ def __init__(self, canvas):
27632764
self.mode = '' # a mode string for the status bar
27642765
self.set_history_buttons()
27652766

2767+
@partial(canvas.mpl_connect, 'draw_event')
2768+
def define_home(event):
2769+
self.push_current()
2770+
# The decorator sets `define_home` to the callback cid, so we can
2771+
# disconnect it after the first use.
2772+
canvas.mpl_disconnect(define_home)
2773+
27662774
def set_message(self, s):
27672775
"""Display a message on toolbar or in status bar"""
27682776
pass
@@ -2913,11 +2921,6 @@ def press_pan(self, event):
29132921
return
29142922

29152923
x, y = event.x, event.y
2916-
2917-
# push the current view to define home if stack is empty
2918-
if self._views.empty():
2919-
self.push_current()
2920-
29212924
self._xypress = []
29222925
for i, a in enumerate(self.canvas.figure.get_axes()):
29232926
if (x is not None and y is not None and a.in_axes(event) and
@@ -2953,11 +2956,6 @@ def press_zoom(self, event):
29532956
return
29542957

29552958
x, y = event.x, event.y
2956-
2957-
# push the current view to define home if stack is empty
2958-
if self._views.empty():
2959-
self.push_current()
2960-
29612959
self._xypress = []
29622960
for i, a in enumerate(self.canvas.figure.get_axes()):
29632961
if (x is not None and y is not None and a.in_axes(event) and

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def apply_callback(data):
234234
# Redraw
235235
figure = axes.get_figure()
236236
figure.canvas.draw()
237+
figure.canvas.toolbar.push_current()
237238

238239
data = formlayout.fedit(datalist, title="Figure options", parent=parent,
239240
icon=get_icon('qt4_editor_options.svg'),

0 commit comments

Comments
 (0)
0