Skip to content
Merged
Show file tree
Hide file tree
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: 8 additions & 10 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from six.moves import xrange

from contextlib import contextmanager
from functools import partial
import importlib
import io
import itertools
Expand Down Expand Up @@ -2833,6 +2834,13 @@ def __init__(self, canvas):
self.mode = '' # a mode string for the status bar
self.set_history_buttons()

@partial(canvas.mpl_connect, 'draw_event')
def define_home(event):
self.push_current()
# The decorator sets `define_home` to the callback cid, so we can
# disconnect it after the first use.
canvas.mpl_disconnect(define_home)

def set_message(self, s):
"""Display a message on toolbar or in status bar."""

Expand Down Expand Up @@ -2982,11 +2990,6 @@ def press_pan(self, event):
return

x, y = event.x, event.y

# push the current view to define home if stack is empty
if self._views.empty():
self.push_current()

self._xypress = []
for i, a in enumerate(self.canvas.figure.get_axes()):
if (x is not None and y is not None and a.in_axes(event) and
Expand Down Expand Up @@ -3022,11 +3025,6 @@ def press_zoom(self, event):
return

x, y = event.x, event.y

# push the current view to define home if stack is empty
if self._views.empty():
self.push_current()

self._xypress = []
for i, a in enumerate(self.canvas.figure.get_axes()):
if (x is not None and y is not None and a.in_axes(event) and
Expand Down
6 changes: 6 additions & 0 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def figure_edit(axes, parent=None):
sep = (None, None) # separator

# Get / General
# Cast to builtin floats as they have nicer reprs.
xmin, xmax = map(float, axes.get_xlim())
ymin, ymax = map(float, axes.get_ylim())
general = [('Title', axes.get_title()),
Expand Down Expand Up @@ -177,6 +178,9 @@ def prepare_data(d, init):

def apply_callback(data):
"""This function will be called to apply changes"""
orig_xlim = axes.get_xlim()
orig_ylim = axes.get_ylim()

general = data.pop(0)
curves = data.pop(0) if has_curve else []
images = data.pop(0) if has_image else []
Expand Down Expand Up @@ -248,6 +252,8 @@ def apply_callback(data):
# Redraw
figure = axes.get_figure()
figure.canvas.draw()
if not (axes.get_xlim() == orig_xlim and axes.get_ylim() == orig_ylim):
figure.canvas.toolbar.push_current()

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