Skip to content

Commit 3377467

Browse files
author
James Evans
committed
The figure option dialog resets the axes and all unit information. This fixes
it so that unit information is not lost.
1 parent 7900ee4 commit 3377467

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ def figure_edit(axes, parent=None):
6363
('(Re-)Generate automatic legend', False),
6464
]
6565

66+
# Save the unit data
67+
xconverter = axes.xaxis.converter
68+
yconverter = axes.yaxis.converter
69+
xunits = axes.xaxis.get_units()
70+
yunits = axes.yaxis.get_units()
71+
6672
if has_curve:
6773
# Get / Curves
6874
linedict = {}
@@ -101,7 +107,7 @@ def figure_edit(axes, parent=None):
101107
has_curve = bool(curves)
102108

103109
datalist = [(general, "Axes", "")]
104-
if has_curve:
110+
if has_curve and curves:
105111
datalist.append((curves, "Curves", ""))
106112

107113
def apply_callback(data):
@@ -122,6 +128,14 @@ def apply_callback(data):
122128
axes.set_ylim(ymin, ymax)
123129
axes.set_ylabel(ylabel)
124130

131+
# Restore the unit data
132+
axes.xaxis.converter = xconverter
133+
axes.yaxis.converter = yconverter
134+
axes.xaxis.set_units( xunits )
135+
axes.yaxis.set_units( yunits )
136+
axes.xaxis._update_axisinfo()
137+
axes.yaxis._update_axisinfo()
138+
125139
if has_curve:
126140
# Set / Curves
127141
for index, curve in enumerate(curves):

0 commit comments

Comments
 (0)