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

Re-Generate legend, through apply_callback/Apply #2947

Merged
merged 6 commits into from May 2, 2014
Merged
Changes from 4 commits
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
14 changes: 13 additions & 1 deletion lib/matplotlib/backends/qt4_editor/figureoptions.py
Expand Up @@ -54,6 +54,8 @@ def figure_edit(axes, parent=None):
('Min', ymin), ('Max', ymax),
('Label', axes.get_ylabel()),
('Scale', [axes.get_yscale(), 'linear', 'log'])
Copy link
Member

Choose a reason for hiding this comment

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

You are missing a , here

sep,
('(Re-)Generate automatic legend', False) #defaults to False, as it clobbers carefully hand crafted legends /2014-04-22
Copy link
Member

Choose a reason for hiding this comment

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

This file is apparently not tested for pep8 compliance, but could you wrap the long line and in-line comments should be of the form

stuff  # comment

It seems petty and dumb, but maintaining a consistent style really does help with the readablity of the code (which it turn helps out the devs who spend lots of time reading said code).

There is no need to put dates/name in-line, git keeps track of that for us.

]

if has_curve:
Expand Down Expand Up @@ -98,7 +100,7 @@ def apply_callback(data):
general, = data

# Set / General
title, xmin, xmax, xlabel, xscale, ymin, ymax, ylabel, yscale = general
title, xmin, xmax, xlabel, xscale, ymin, ymax, ylabel, yscale, generate_legend = general #/2014-04-22
axes.set_xscale(xscale)
axes.set_yscale(yscale)
axes.set_title(title)
Expand All @@ -122,6 +124,16 @@ def apply_callback(data):
line.set_markersize(markersize)
line.set_markerfacecolor(markerfacecolor)
line.set_markeredgecolor(markeredgecolor)

# re-generate legend, if checkbox is checked. Stefan Kraus/tacaswell 2014-04-22
if generate_legend:
if axes.legend_ is not None:
old_legend = axes.get_legend()
new_legend = axes.legend(ncol = old_legend._ncol)
new_legend.draggable(old_legend._draggable is not None)
else:
new_legend = axes.legend()
new_legend.draggable(True)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we want to default to draggable legends


# Redraw
figure = axes.get_figure()
Expand Down