matplotlib.legend
The legend module defines the Legend class, which is responsible for drawing legends associated with axes and/or figures.
Important
It is unlikely that you would ever create a Legend instance manually. Most users would normally create a legend via the ~.Axes.legend function. For more details on legends there is also a legend guide.
The Legend class is a container of legend handles and legend texts.
The legend handler map specifies how to create legend handles from artists
(lines, patches, etc.) in the axes or figures. Default legend handlers are
defined in the legend_handler
module. While not all artist
types are covered by the default legend handlers, custom legend handlers can be
defined to support arbitrary objects.
See the legend guide for more information.