8000 Don't push axes state if it wasn't edited. · matplotlib/matplotlib@486f0b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 486f0b1

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 70dcaa6 commit 486f0b1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ def figure_edit(axes, parent=None):
4545
sep = (None, None) # separator
4646

4747
# Get / General
48-
xmin, xmax = map(float, axes.get_xlim())
49-
ymin, ymax = map(float, axes.get_ylim())
48+
# Cast to builtin floats as they have nicer reprs.
49+
orig_xmin, orig_xmax = map(float, axes.get_xlim())
50+
orig_ymin, orig_ymax = map(float, axes.get_ylim())
5051
general = [('Title', axes.get_title()),
5152
sep,
5253
(None, "<b>X-Axis</b>"),
53-
('Min', xmin), ('Max', xmax),
54+
('Min', orig_xmin), ('Max', orig_xmax),
5455
('Label', axes.get_xlabel()),
5556
('Scale', [axes.get_xscale(), 'linear', 'log']),
5657
sep,
5758
(None, "<b>Y-Axis</b>"),
58-
('Min', ymin), ('Max', ymax),
59+
('Min', orig_ymin), ('Max', orig_ymax),
5960
('Label', axes.get_ylabel()),
6061
('Scale', [axes.get_yscale(), 'linear', 'log']),
6162
sep,
@@ -166,6 +167,9 @@ def prepare_data(d, init):
166167

167168
def apply_callback(data):
168169
"""This function will be called to apply changes"""
170+
orig_xlim = axes.get_xlim()
171+
orig_ylim = axes.get_ylim()
172+
169173
general = data.pop(0)
170174
curves = data.pop(0) if has_curve else []
171175
images = data.pop(0) if has_image else []
@@ -234,7 +238,8 @@ def apply_callback(data):
234238
# Redraw
235239
figure = axes.get_figure()
236240
figure.canvas.draw()
237-
figure.canvas.toolbar.push_current()
241+
if not (axes.get_xlim() == orig_xlim and axes.get_ylim() == orig_ylim):
242+
figure.canvas.toolbar.push_current()
238243

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

0 commit comments

Comments
 (0)
0