Skip to content

Commit d601ad1

Browse files
committed
Don't push axes state if it wasn't edited.
Thanks to @tacaswell for fixing the case where the multiple edits are applied consecutively.
1 parent fb83117 commit d601ad1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def figure_edit(axes, parent=None):
4747
sep = (None, None) # separator
4848

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

178179
def apply_callback(data):
179180
"""This function will be called to apply changes"""
181+
orig_xlim = axes.get_xlim()
182+
orig_ylim = axes.get_ylim()
183+
180184
general = data.pop(0)
181185
curves = data.pop(0) if has_curve else []
182186
images = data.pop(0) if has_image else []
@@ -248,7 +252,8 @@ def apply_callback(data):
248252
# Redraw
249253
figure = axes.get_figure()
250254
figure.canvas.draw()
251-
figure.canvas.toolbar.push_current()
255+
if not (axes.get_xlim() == orig_xlim and axes.get_ylim() == orig_ylim):
256+
figure.canvas.toolbar.push_current()
252257

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

0 commit comments

Comments
 (0)