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

Skip to content

Commit 39ae61a

Browse files
committed
FIX: legend crashes when bar chart is empty with label
1 parent 2208665 commit 39ae61a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/legend_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox)
3535

3636

3737
def update_from_first_child(tgt, src):
38-
tgt.update_from(src.get_children()[0])
38+
first_child = next(iter(src.get_children()), None)
39+
if first_child is not None:
40+
tgt.update_from(first_child)
3941

4042

4143
class HandlerBase(object):

0 commit comments

Comments
 (0)