matplotlib.legend_handler

Default legend handlers.

Important

This is a low-level legend API, which most end users do not need.

We recommend that you are familiar with the legend guide before reading this documentation.

Legend handlers are expected to be a callable object with a following signature:

legend_handler(legend, orig_handle, fontsize, handlebox)

Where legend is the legend itself, orig_handle is the original plot, fontsize is the fontsize in pixels, and handlebox is an .OffsetBox instance. Within the call, you should create relevant artists (using relevant properties from the legend and/or orig_handle) and add them into the handlebox. The artists need to be scaled according to the fontsize (note that the size is in pixels, i.e., this is dpi-scaled value).

This module includes definition of several legend handler classes derived from the base class (HandlerBase) with the following method:

def legend_artist(self, legend, orig_handle, fontsize, handlebox)