ferrum.legend¶
Per-channel legend configuration.
The Legend dataclass controls legend appearance — title, orientation, direction,
symbols, gradients, and positioning. Pass a Legend instance to an encoding
channel's legend= parameter, or use legend=False to suppress the legend.
Legend
dataclass
¶
Per-channel legend configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Legend title text. |
None
|
orient
|
str
|
Legend position ("right", "left", "top", "bottom", "none"). |
'right'
|
direction
|
str
|
Layout direction ("vertical", "horizontal"). |
'vertical'
|
type
|
str
|
Legend type ("symbol", "gradient"). |
None
|
tick_count
|
int
|
Number of ticks for gradient legends. |
None
|
tick_min_step
|
float
|
Minimum tick step. |
None
|
values
|
list
|
Explicit legend values. |
None
|
format
|
str
|
Label format string. |
None
|
format_type
|
str
|
Format type. |
None
|
label_font_size
|
float
|
Label font size. |
None
|
label_color
|
str
|
Label color. |
None
|
label_limit
|
float
|
Maximum label width. |
None
|
symbol_size
|
float
|
Symbol size. |
None
|
symbol_stroke_width
|
float
|
Symbol stroke width. |
None
|
symbol_type
|
str
|
Symbol shape type. |
None
|
gradient_length
|
float
|
Gradient legend length. |
None
|
gradient_thickness
|
float
|
Gradient legend thickness. |
None
|
columns
|
int
|
Number of columns for multi-column layout. |
None
|
column_padding
|
float
|
Padding between columns. |
None
|
row_padding
|
float
|
Padding between rows. |
None
|
clip_height
|
float
|
Clip height for legend. |
None
|
title_font_size
|
float
|
Title font size. |
None
|
title_padding
|
float
|
Title padding. |
None
|
offset
|
float
|
Offset from plot. |
None
|
padding
|
float
|
Internal padding. |
None
|
zindex
|
int
|
Z-index. |
None
|
Examples:
>>> import ferrum as fm
>>> leg = fm.Legend(title="Species", orient="top")
>>> leg.title
'Species'
>>> leg.to_dict()
{'title': 'Species', 'orient': 'top'}
to_dict ¶
Serialize to dict for the renderer, omitting None and default values.