legendkit.cat_legend¶
- class legendkit.cat_legend(ax=None, colors=None, labels=None, size=1, handle=None, handler_kw=None, fill=True, **kwargs)¶
Categorical legend with same handles
This is useful to create legend that share the same handle but with different colors
- Parameters:
- ax
Axes The axes to draw the legend
- colorsarray-like
The color for each legend item
- labelsarray-like
The text for each legend item
- handlestr or handle object, default: ‘rect’
The handle to be used for every entry, see
legendkit.legend- handler_kwmapping
Use this to control the style of handler
- fillbool, default: True
If not filled, the color will draw on the edge.
- sizefloat, default: 1.0
The size of legend handle
- kwargs
Pass to
legendkit.legend()
- ax
Examples
Create a legend easily
>>> from legendkit import cat_legend >>> _, ax = plt.subplots(figsize=(1, 1)) >>> ax.set_axis_off() >>> cat_legend(ax, ... colors=["red", "blue", "green"], ... labels=["Item 1", "Item 2", "Item 3"], ... )