matplotlib 3.5.1

ParametersReturns
_parse_legend_args(axs, *args, handles=None, labels=None, **kwargs)

The parser is a bit involved because we support:

legend()
legend(labels)
legend(handles, labels)
legend(labels=labels)
legend(handles=handles)
legend(handles=handles, labels=labels)

The behavior for a mixture of positional and keyword handles and labels is undefined and issues a warning.

Parameters

axs : list of `.Axes`

If handles are not given explicitly, the artists in these Axes are used as handles.

*args : tuple

Positional parameters passed to legend() .

handles :

The value of the keyword argument legend(handles=...) , or None if that keyword argument was not used.

labels :

The value of the keyword argument legend(labels=...) , or None if that keyword argument was not used.

**kwargs :

All other keyword arguments passed to legend() .

Returns

handles : list of `.Artist`

The legend handles.

labels : list of str

The legend labels.

extra_args : tuple

args with positional handles and labels removed.

kwargs : dict

kwargs with keywords handles and labels removed.

Get the handles and labels from the calls to either figure.legend or axes.legend .

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/legend.py#1147
type: <class 'function'>
Commit: