marsilea.base.LegendMaker#

class LegendMaker#

Bases: object

The factory class to handle legends

add_legends(side='right', pad=0.0, order=None, stack_by=None, stack_size=3, align_legends=None, align_stacks=None, legend_spacing=10, stack_spacing=10, box_padding=2)#

Draw legend based on the order of annotation

Note

If you want to concatenate plots, please add legend after concatenation, this will merge legends from every plots

Stack is a pack of legends

Parameters:
side{‘right’, ‘left’, ‘top’, ‘bottom’}, default: ‘right’

Which side to draw legend

padnumber, default: 0

The padding of the legend in inches

orderarray of plot name

The order of the legend, if None, the order will be the same as the order when adding plotters. You need to set name for each plotter when adding them, and specify the order here.

stack_by{‘row’, ‘col’}

The direction to stack legends

stack_sizeint, default: 3

The number of legends in a stack

align_legends{‘left’, ‘right’, ‘top’, ‘bottom’}

The side to align legends in a stack

align_stacks{‘left’, ‘right’, ‘top’, ‘bottom’}

The side to align stacks

legend_spacingfloat, default: 10

The space between legends

stack_spacingfloat, default: 10

The space between stacks

box_paddingfloat, default: 2

Add pad around the whole legend box

custom_legend(legend_func, name=None)#

Add a custom legend

Parameters:
legend_funcCallable

A function that return the legend object, the legend must be an Artist <matplotlib.artist.Artists>

namestr, optional

The name of the legend

layout#
remove_legends()#