Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07930c0

Browse files
author
anykraus
committed
re-generate legend: fixes
Fixed crash if there was no previous legend. Fixed ncol inheritance.
1 parent 80beedf commit 07930c0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/matplotlib/backends/qt4_editor/figureoptions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ def apply_callback(data):
127127

128128
# re-generate legend, if checkbox is checked. Stefan Kraus/tacaswell 2014-04-22
129129
if generate_legend:
130-
old_legend = axes.get_legend()
131-
new_legend = axes.legend()
132-
new_legend._ncol = old_legend._ncol
133-
new_legend.draggable(old_legend._draggable is not None)
130+
if axes.legend_ is not None:
131+
old_legend = axes.get_legend()
132+
new_legend = axes.legend(ncol = old_legend._ncol)
133+
new_legend.draggable(old_legend._draggable is not None)
134+
else:
135+
new_legend = axes.legend()
136+
new_legend.draggable(True)
134137

135138
# Redraw
136139
figure = axes.get_figure()

0 commit comments

Comments
 (0)