Skip to content

Navigation Menu

Sign in
Appearance settings

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

Appearance settings

Commit 8b5e226

Browse filesBrowse 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
Copy full SHA for 8b5e226

File tree

Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed

‎lib/matplotlib/backends/qt_editor/figureoptions.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_editor/figureoptions.py
+8-5Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.