Skip to content

Commit d950eea

Browse files
committed
Don't show empty legend
1 parent d5c3c7e commit d950eea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

xplt/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,8 @@ def legend(self, subplot="all", show=True, **kwargs):
765765
labels = [h.get_label() for h in handle_map]
766766

767767
# show legend
768-
ax.legend(handles=handles, labels=labels, **kwargs)
768+
if len(handles) > 0:
769+
ax.legend(handles=handles, labels=labels, **kwargs)
769770

770771
def autoscale(self, subplot="all", *, reset=False, freeze=True, tight=None):
771772
"""Autoscale the axes of a subplot

0 commit comments

Comments
 (0)