Skip to content
Merged
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
Make warning for no-handles legend more explicit.
It may be slightly better to only emit the longer message if there were
actually handles that got ignored because of the leading underscore, but
that's actually a bit annoying to check (or requires some refactoring of
_get_legend_handles_labels).
  • Loading branch information
anntzer committed Aug 31, 2021
commit fc7bc44dc5aa712b3d750bfd7029ac545aa727d9
5 changes: 4 additions & 1 deletion lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,10 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
elif len(args) == 0:
handles, labels = _get_legend_handles_labels(axs, handlers)
if not handles:
log.warning('No handles with labels found to put in legend.')
log.warning(
"No artists with labels found to put in legend. Note that "
"artists whose label start with an underscore are ignored "
"when legend() is called with no argument.")

# One argument. User defined labels - automatic handle detection.
elif len(args) == 1:
Expand Down