Skip to content

Commit

Permalink
FIX: handle empty legend in qt figureoption
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Jul 8, 2015
1 parent 9410ddb commit c836c56
Showing 1 changed file with 8 additions and 5 deletions.
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 comments on commit c836c56

Please sign in to comment.