8000 FIX: handle empty legend in qt figureoption · matplotlib/matplotlib@c836c56 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit c836c56

Browse files
committed
FIX: handle empty legend in qt figureoption
Closes #4599
1 parent 9410ddb commit c836c56

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,17 @@ def apply_callback(data):
141141
line.set_markeredgecolor(markeredgecolor)
142142

143143
# re-generate legend, if checkbox is checked
144+
144145
if generate_legend:
146+
draggable = None
147+
ncol = None
145148
if axes.legend_ is not None:
146149
old_legend = axes.get_legend()
147-
new_legend = axes.legend(ncol=old_legend._ncol)
148-
new_legend.draggable(old_legend._draggable is not None)
149-
else:
150-
new_legend = axes.legend()
151-
new_legend.draggable(True)
150+
draggable = old_legend._draggable is not None
151+
ncol = old_legend._ncol
152+
new_legend = axes.legend(ncol=ncol)
153+
if new_legend:
154+
new_legend.draggable(draggable)
152155

153156
# Redraw
154157
figure = axes.get_figure()

0 commit comments

Comments
 (0)
0