8000 Make warning for no-handles legend more explicit. · matplotlib/matplotlib@fc7bc44 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc7bc44

Browse files
committed
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).
1 parent 1d12973 commit fc7bc44

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/legend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,10 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
12241224
elif len(args) == 0:
12251225
handles, labels = _get_legend_handles_labels(axs, handlers)
12261226
if not handles:
1227-
log.warning('No handles with labels found to put in legend.')
1227+
log.warning(
1228+
"No artists with labels found to put in legend. Note that "
1229+
"artists whose label start with an underscore are ignored "
1230+
"when legend() is called with no argument.")
12281231

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

0 commit comments

Comments
 (0)
0