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

Skip to content

Commit 70dcaa6

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 6b1adfd commit 70dcaa6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lib/matplotlib/backend_bases.py

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

4141
from contextlib import contextmanager
42+
from functools import partial
4243
import importlib
4344
import io
4445
import os
@@ -51,7 +52,6 @@
5152
import matplotlib.colors as colors
5253
import matplotlib.transforms as transforms
5354
import matplotlib.widgets as widgets
54-
#import matplotlib.path as path
5555
from matplotlib import rcParams
5656
from matplotlib import is_interactive
5757
from matplotlib import get_backend
@@ -2756,6 +2756,13 @@ def __init__(self, canvas):
27562756
self.mode = '' # a mode string for the status bar
27572757
self.set_history_buttons()
27582758

2759+
@partial(canvas.mpl_connect, 'draw_event')
2760+
def define_home(event):
2761+
self.push_current()
2762+
# The decorator sets `define_home` to the callback cid, so we can
2763+
# disconnect it after the first use.
2764+
canvas.mpl_disconnect(define_home)
2765+
27592766
def set_message(self, s):
27602767
"""Display a message on toolbar or in status bar"""
27612768
pass
@@ -2906,11 +2913,6 @@ def press_pan(self, event):
29062913
return
29072914

29082915
x, y = event.x, event.y
2909-
2910-
# push the current view to define home if stack is empty
2911-
if self._views.empty():
2912-
self.push_current()
2913-
29142916
self._xypress = []
29152917
for i, a in enumerate(self.canvas.figure.get_axes()):
29162918
if (x is not None and y is not None and a.in_axes(event) and
@@ -2946,11 +2948,6 @@ def press_zoom(self, event):
29462948
return
29472949

29482950
x, y = event.x, event.y
2949-
2950-
# push the current view to define home if stack is empty
2951-
if self._views.empty():
2952-
self.push_current()
2953-
29542951
self._xypress = []
29552952
for i, a in enumerate(self.canvas.figure.get_axes()):
29562953
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