Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

figure option dialog does not properly handle units #4909

Merged
merged 2 commits into from Sep 13, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/matplotlib/backends/qt_editor/figureoptions.py
Expand Up @@ -63,6 +63,12 @@ def figure_edit(axes, parent=None):
('(Re-)Generate automatic legend', False),
]

# Save the unit data
xconverter = axes.xaxis.converter
yconverter = axes.yaxis.converter
xunits = axes.xaxis.get_units()
yunits = axes.yaxis.get_units()

if has_curve:
# Get / Curves
linedict = {}
Expand Down Expand Up @@ -101,7 +107,7 @@ def figure_edit(axes, parent=None):
has_curve = bool(curves)

datalist = [(general, "Axes", "")]
if has_curve:
if has_curve and curves:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the and curves doing?

datalist.append((curves, "Curves", ""))

def apply_callback(data):
Expand All @@ -122,6 +128,14 @@ def apply_callback(data):
axes.set_ylim(ymin, ymax)
axes.set_ylabel(ylabel)

# Restore the unit data
axes.xaxis.converter = xconverter
axes.yaxis.converter = yconverter
axes.xaxis.set_units( xunits )
axes.yaxis.set_units( yunits )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8: unnecessary spaces

axes.xaxis._update_axisinfo()
axes.yaxis._update_axisinfo()

if has_curve:
# Set / Curves
for index, curve in enumerate(curves):
Expand Down