X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/matplotlib/legend_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox)


def update_from_first_child(tgt, src):
tgt.update_from(src.get_children()[0])
first_child = next(iter(src.get_children()), None)
if first_child is not None:
tgt.update_from(first_child)


class HandlerBase(object):
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ def test_handler_numpoints():
ax.legend(numpoints=0.5)


def test_empty_bar_chart_with_legend():
"""Test legend when bar chart is empty with a label."""
# related to issue #13003. Calling plt.legend() should not
# raise an IndexError.
plt.bar([], [], label='test')
plt.legend()


def test_shadow_framealpha():
# Test if framealpha is activated when shadow is True
# and framealpha is not explicitly passed'''
Expand Down
X Tutup