altair.LegendConfig#
- class altair.LegendConfig(aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, disable=Undefined, fillColor=Undefined, gradientDirection=Undefined, gradientHorizontalMaxLength=Undefined, gradientHorizontalMinLength=Undefined, gradientLabelLimit=Undefined, gradientLabelOffset=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gradientVerticalMaxLength=Undefined, gradientVerticalMinLength=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, layout=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, strokeDash=Undefined, strokeWidth=Undefined, symbolBaseFillColor=Undefined, symbolBaseStrokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolDirection=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, unselectedOpacity=Undefined, zindex=Undefined, **kwds)#
LegendConfig schema wrapper
Mapping(required=[])
- Parameters:
- ariaanyOf(boolean,
ExprRef
) A boolean flag indicating if ARIA attributes should be included (SVG output only). If
false
, the “aria-hidden” attribute will be set on the output SVG group, removing the legend from the ARIA accessibility tree.Default value:
true
- clipHeightanyOf(float,
ExprRef
) The height in pixels to clip symbol legend entries and limit their size.
- columnPaddinganyOf(float,
ExprRef
) The horizontal padding in pixels between symbol legend entries.
Default value:
10
.- columnsanyOf(float,
ExprRef
) The number of columns in which to arrange symbol legend entries. A value of
0
or lower indicates a single row with one column per entry.- cornerRadiusanyOf(float,
ExprRef
) Corner radius for the full legend.
- descriptionanyOf(string,
ExprRef
) A text description of this legend for ARIA accessibility (SVG output only). If the
aria
property is true, for SVG output the “aria-label” attribute will be set to this description. If the description is unspecified it will be automatically generated.- direction
Orientation
The direction of the legend, one of
"vertical"
or"horizontal"
.Default value:
For top-/bottom-
orient
ed legends,"horizontal"
For left-/right-
orient
ed legends,"vertical"
For top/bottom-left/right-
orient
ed legends,"horizontal"
for gradient legends and"vertical"
for symbol legends.
- disableboolean
Disable legend by default
- fillColoranyOf(anyOf(None,
Color
),ExprRef
) Background fill color for the full legend.
- gradientDirectionanyOf(
Orientation
,ExprRef
) The default direction (
"horizontal"
or"vertical"
) for gradient legends.Default value:
"vertical"
.- gradientHorizontalMaxLengthfloat
Max legend length for a horizontal gradient when
config.legend.gradientLength
is undefined.Default value:
200
- gradientHorizontalMinLengthfloat
Min legend length for a horizontal gradient when
config.legend.gradientLength
is undefined.Default value:
100
- gradientLabelLimitanyOf(float,
ExprRef
) The maximum allowed length in pixels of color ramp gradient labels.
- gradientLabelOffsetanyOf(float,
ExprRef
) Vertical offset in pixels for color ramp gradient labels.
Default value:
2
.- gradientLengthanyOf(float,
ExprRef
) The length in pixels of the primary axis of a color gradient. This value corresponds to the height of a vertical gradient or the width of a horizontal gradient.
Default value:
200
.- gradientOpacityanyOf(float,
ExprRef
) Opacity of the color gradient.
- gradientStrokeColoranyOf(anyOf(None,
Color
),ExprRef
) The color of the gradient stroke, can be in hex color code or regular color name.
Default value:
"lightGray"
.- gradientStrokeWidthanyOf(float,
ExprRef
) The width of the gradient stroke, in pixels.
Default value:
0
.- gradientThicknessanyOf(float,
ExprRef
) The thickness in pixels of the color gradient. This value corresponds to the width of a vertical gradient or the height of a horizontal gradient.
Default value:
16
.- gradientVerticalMaxLengthfloat
Max legend length for a vertical gradient when
config.legend.gradientLength
is undefined.Default value:
200
- gradientVerticalMinLengthfloat
Min legend length for a vertical gradient when
config.legend.gradientLength
is undefined.Default value:
100
- gridAlignanyOf(
LayoutAlign
,ExprRef
) The alignment to apply to symbol legends rows and columns. The supported string values are
"all"
,"each"
(the default), andnone
. For more information, see the grid layout documentation.Default value:
"each"
.- labelAlignanyOf(
Align
,ExprRef
) The alignment of the legend label, can be left, center, or right.
- labelBaselineanyOf(
TextBaseline
,ExprRef
) The position of the baseline of legend label, can be
"top"
,"middle"
,"bottom"
, or"alphabetic"
.Default value:
"middle"
.- labelColoranyOf(anyOf(None,
Color
),ExprRef
) The color of the legend label, can be in hex color code or regular color name.
- labelFontanyOf(string,
ExprRef
) The font of the legend label.
- labelFontSizeanyOf(float,
ExprRef
) The font size of legend label.
Default value:
10
.- labelFontStyleanyOf(
FontStyle
,ExprRef
) The font style of legend label.
- labelFontWeightanyOf(
FontWeight
,ExprRef
) The font weight of legend label.
- labelLimitanyOf(float,
ExprRef
) Maximum allowed pixel width of legend tick labels.
Default value:
160
.- labelOffsetanyOf(float,
ExprRef
) The offset of the legend label.
Default value:
4
.- labelOpacityanyOf(float,
ExprRef
) Opacity of labels.
- labelOverlapanyOf(
LabelOverlap
,ExprRef
) The strategy to use for resolving overlap of labels in gradient legends. If
false
, no overlap reduction is attempted. If set totrue
or"parity"
, a strategy of removing every other label is used. If set to"greedy"
, a linear scan of the labels is performed, removing any label that overlaps with the last visible label (this often works better for log-scaled axes).Default value:
"greedy"
forlog scales otherwise
true`.- labelPaddinganyOf(float,
ExprRef
) Padding in pixels between the legend and legend labels.
- labelSeparationanyOf(float,
ExprRef
) The minimum separation that must be between label bounding boxes for them to be considered non-overlapping (default
0
). This property is ignored if labelOverlap resolution is not enabled.- layout
ExprRef
- legendXanyOf(float,
ExprRef
) Custom x-position for legend with orient “none”.
- legendYanyOf(float,
ExprRef
) Custom y-position for legend with orient “none”.
- offsetanyOf(float,
ExprRef
) The offset in pixels by which to displace the legend from the data rectangle and axes.
Default value:
18
.- orient
LegendOrient
The orientation of the legend, which determines how the legend is positioned within the scene. One of
"left"
,"right"
,"top"
,"bottom"
,"top-left"
,"top-right"
,"bottom-left"
,"bottom-right"
,"none"
.Default value:
"right"
- paddinganyOf(float,
ExprRef
) The padding between the border and content of the legend group.
Default value:
0
.- rowPaddinganyOf(float,
ExprRef
) The vertical padding in pixels between symbol legend entries.
Default value:
2
.- strokeColoranyOf(anyOf(None,
Color
),ExprRef
) Border stroke color for the full legend.
- strokeDashanyOf(List(float),
ExprRef
) Border stroke dash pattern for the full legend.
- strokeWidthanyOf(float,
ExprRef
) Border stroke width for the full legend.
- symbolBaseFillColoranyOf(anyOf(None,
Color
),ExprRef
) Default fill color for legend symbols. Only applied if there is no
"fill"
scale color encoding for the legend.Default value:
"transparent"
.- symbolBaseStrokeColoranyOf(anyOf(None,
Color
),ExprRef
) Default stroke color for legend symbols. Only applied if there is no
"fill"
scale color encoding for the legend.Default value:
"gray"
.- symbolDashanyOf(List(float),
ExprRef
) An array of alternating [stroke, space] lengths for dashed symbol strokes.
- symbolDashOffsetanyOf(float,
ExprRef
) The pixel offset at which to start drawing with the symbol stroke dash array.
- symbolDirectionanyOf(
Orientation
,ExprRef
) The default direction (
"horizontal"
or"vertical"
) for symbol legends.Default value:
"vertical"
.- symbolFillColoranyOf(anyOf(None,
Color
),ExprRef
) The color of the legend symbol,
- symbolLimitanyOf(float,
ExprRef
) The maximum number of allowed entries for a symbol legend. Additional entries will be dropped.
- symbolOffsetanyOf(float,
ExprRef
) Horizontal pixel offset for legend symbols.
Default value:
0
.- symbolOpacityanyOf(float,
ExprRef
) Opacity of the legend symbols.
- symbolSizeanyOf(float,
ExprRef
) The size of the legend symbol, in pixels.
Default value:
100
.- symbolStrokeColoranyOf(anyOf(None,
Color
),ExprRef
) Stroke color for legend symbols.
- symbolStrokeWidthanyOf(float,
ExprRef
) The width of the symbol’s stroke.
Default value:
1.5
.- symbolTypeanyOf(
SymbolShape
,ExprRef
) The symbol shape. One of the plotting shapes
circle
(default),square
,cross
,diamond
,triangle-up
,triangle-down
,triangle-right
, ortriangle-left
, the line symbolstroke
, or one of the centered directional shapesarrow
,wedge
, ortriangle
. Alternatively, a custom SVG path string can be provided. For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.Default value:
"circle"
.- tickCountanyOf(
TickCount
,ExprRef
) The desired number of tick values for quantitative legends.
- titleNone
Set to null to disable title for the axis, legend, or header.
- titleAlignanyOf(
Align
,ExprRef
) Horizontal text alignment for legend titles.
Default value:
"left"
.- titleAnchoranyOf(
TitleAnchor
,ExprRef
) Text anchor position for placing legend titles.
- titleBaselineanyOf(
TextBaseline
,ExprRef
) Vertical text baseline for legend titles. One of
"alphabetic"
(default),"top"
,"middle"
,"bottom"
,"line-top"
, or"line-bottom"
. The"line-top"
and"line-bottom"
values operate similarly to"top"
and"bottom"
, but are calculated relative to the lineHeight rather than fontSize alone.Default value:
"top"
.- titleColoranyOf(anyOf(None,
Color
),ExprRef
) The color of the legend title, can be in hex color code or regular color name.
- titleFontanyOf(string,
ExprRef
) The font of the legend title.
- titleFontSizeanyOf(float,
ExprRef
) The font size of the legend title.
- titleFontStyleanyOf(
FontStyle
,ExprRef
) The font style of the legend title.
- titleFontWeightanyOf(
FontWeight
,ExprRef
) The font weight of the legend title. This can be either a string (e.g
"bold"
,"normal"
) or a number (100
,200
,300
, …,900
where"normal"
=400
and"bold"
=700
).- titleLimitanyOf(float,
ExprRef
) Maximum allowed pixel width of legend titles.
Default value:
180
.- titleLineHeightanyOf(float,
ExprRef
) Line height in pixels for multi-line title text or title text with
"line-top"
or"line-bottom"
baseline.- titleOpacityanyOf(float,
ExprRef
) Opacity of the legend title.
- titleOrientanyOf(
Orient
,ExprRef
) Orientation of the legend title.
- titlePaddinganyOf(float,
ExprRef
) The padding, in pixels, between title and legend.
Default value:
5
.- unselectedOpacityfloat
The opacity of unselected legend entries.
Default value: 0.35.
- zindexanyOf(float,
ExprRef
) The integer z-index indicating the layering of the legend group relative to other axis, mark, and legend groups.
- ariaanyOf(boolean,
- __init__(aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, disable=Undefined, fillColor=Undefined, gradientDirection=Undefined, gradientHorizontalMaxLength=Undefined, gradientHorizontalMinLength=Undefined, gradientLabelLimit=Undefined, gradientLabelOffset=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gradientVerticalMaxLength=Undefined, gradientVerticalMinLength=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, layout=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, strokeDash=Undefined, strokeWidth=Undefined, symbolBaseFillColor=Undefined, symbolBaseStrokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolDirection=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, unselectedOpacity=Undefined, zindex=Undefined, **kwds)#
Methods
__init__
([aria, clipHeight, columnPadding, ...])copy
([deep, ignore])Return a copy of the object
from_dict
(dct[, validate, _wrapper_classes])Construct class from a dictionary representation
from_json
(json_string[, validate])Instantiate the object from a valid JSON string
resolve_references
([schema])Resolve references in the context of this object's schema or root schema.
to_dict
([validate, ignore, context])Return a dictionary representation of the object
to_json
([validate, ignore, context, indent, ...])Emit the JSON representation for this object as a string.
validate
(instance[, schema])Validate the instance against the class schema in the context of the rootschema.
validate_property
(name, value[, schema])Validate a property against property schema in the context of the rootschema