8000 Merge pull request #4601 from tacaswell/fix_qt_figureoption_legend · matplotlib/matplotlib@8b5e226 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b5e226

Browse files
committed
Merge pull request #4601 from tacaswell/fix_qt_figureoption_legend
FIX: handle empty legend in qt figureoption
2 parents 9410ddb + c836c56 commit 8b5e226

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