8000 FIX: handle empty legend in qt figureoption by tacaswell · Pull Request #4601 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: handle empty legend in qt figureoption #4601

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
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 8000 view
Diff view
13 changes: 8 additions & 5 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ def apply_callback(data):
line.set_markeredgecolor(markeredgecolor)

# re-generate legend, if checkbox is checked

if generate_legend:
draggable = None
ncol = None
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)
draggable = old_legend._draggable is not None
ncol = old_legend._ncol
new_legend = axes.legend(ncol=ncol)
if new_legend:
new_legend.draggable(draggable)

# Redraw
figure = axes.get_figure()
Expand Down
0