Thanks to visit codestin.com
Credit goes to github.com

Skip to content

figure option dialog does not properly handle units #4909

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

Merged
merged 2 commits into from
Sep 13, 2015
Merged
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
16 changes: 15 additions & 1 deletion lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
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)
axes.xaxis._update_axisinfo()
axes.yaxis._update_axisinfo()

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