legendkit.stack¶
- legendkit.stack(legends, ax=None, orientation: str = 'vertical', spacing=2, padding=2, align='baseline', mode='fixed', loc='lower left', frameon=False, bbox_to_anchor=None, bbox_transform=None, deviation=0.05, title: str = None, title_loc: str = 'top', titlepad=0, alignment: str = 'center', title_fontproperties: Dict = None)¶
Stack multiple artists together
- Parameters:
- legendslist of legends or artists
- axThe axes to draw upon
- orientation{‘vertical’, ‘horizontal’}
- spacingfloat
The space between legends
- paddingfloat
The space around the legends
- alignstr
- mode
- loc
- frameon
- bbox_to_anchor
- bbox_transform
- deviationfloat
The space that deviate from axes
- titlestr
The text of title
- title_loc{‘top’, ‘bottom’, ‘left’, ‘right’}
The location of title
- titlepadfloat
The space between title and legend entries
- alignment{‘left’, ‘center’, ‘right’}
The alignment of the elements inside box
- title_fontpropertiesdict
The font dict that configurate title
Examples
Horizontal stack
>>> from legendkit import cat_legend, hstack >>> _, ax = plt.subplots(figsize=(3, 1)); ax.set_axis_off() >>> args = dict(colors = ["#A7D2CB", "#F2D388"], ... labels = ["Item 1", "Item 2"]) >>> legs = [cat_legend(**args, title=f"Legend {i+1}") for i in range(3)] >>> hstack(legs, title="Horizontal Stack", loc="center", spacing=10, ax=ax)
>>> from legendkit import cat_legend, vstack >>> _, ax = plt.subplots(figsize=(3, 3)); ax.set_axis_off() >>> args = dict(colors = ["#A7D2CB", "#F2D388"], ... labels = ["Item 1", "Item 2"]) >>> legs = [cat_legend(**args, title=f"Legend {i+1}") for i in range(3)] >>> vstack(legs, title="Vertical Stack", loc="center", spacing=10, ax=ax)