altair.Legend#
- class altair.Legend(aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=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, type=Undefined, values=Undefined, zindex=Undefined, **kwds)#
Legend schema wrapper
Mapping(required=[]) Properties of a legend or boolean flag for determining whether to show it.
- Attributes
- ariaanyOf(boolean,
ExprRef
) - clipHeightanyOf(float,
ExprRef
) - columnPaddinganyOf(float,
ExprRef
) - columnsanyOf(float,
ExprRef
) - cornerRadiusanyOf(float,
ExprRef
) - descriptionanyOf(string,
ExprRef
) - 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.
- fillColoranyOf(anyOf(None,
Color
),ExprRef
) - formatanyOf(string,
Dict
) When used with the default
"number"
and"time"
format type, the text formatting pattern for labels of guides (axes, legends, headers) and text marks.If the format type is
"number"
(e.g., for quantitative fields), this is D3’s number format pattern.If the format type is
"time"
(e.g., for temporal fields), this is D3’s time format pattern.
See the format documentation for more examples.
When used with a custom formatType, this value will be passed as
format
alongsidedatum.value
to the registered function.Default value: Derived from numberFormat config for number format and from timeFormat config for time format.
- formatTypestring
The format type for labels. One of
"number"
,"time"
, or a registered custom format type.Default value:
"time"
for temporal fields and ordinal and nominal fields withtimeUnit
."number"
for quantitative fields as well as ordinal and nominal fields withouttimeUnit
.
- gradientLengthanyOf(float,
ExprRef
) - gradientOpacityanyOf(float,
ExprRef
) - gradientStrokeColoranyOf(anyOf(None,
Color
),ExprRef
) - gradientStrokeWidthanyOf(float,
ExprRef
) - gradientThicknessanyOf(float,
ExprRef
) - gridAlignanyOf(
LayoutAlign
,ExprRef
) - labelAlignanyOf(
Align
,ExprRef
) - labelBaselineanyOf(
TextBaseline
,ExprRef
) - labelColoranyOf(anyOf(None,
Color
),ExprRef
) - labelExprstring
Vega expression for customizing labels.
Note: The label text and value can be assessed via the
label
andvalue
properties of the legend’s backingdatum
object.- labelFontanyOf(string,
ExprRef
) - labelFontSizeanyOf(float,
ExprRef
) - labelFontStyleanyOf(
FontStyle
,ExprRef
) - labelFontWeightanyOf(
FontWeight
,ExprRef
) - labelLimitanyOf(float,
ExprRef
) - labelOffsetanyOf(float,
ExprRef
) - labelOpacityanyOf(float,
ExprRef
) - labelOverlapanyOf(
LabelOverlap
,ExprRef
) - labelPaddinganyOf(float,
ExprRef
) - labelSeparationanyOf(float,
ExprRef
) - legendXanyOf(float,
ExprRef
) - legendYanyOf(float,
ExprRef
) - offsetanyOf(float,
ExprRef
) - 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
) - rowPaddinganyOf(float,
ExprRef
) - strokeColoranyOf(anyOf(None,
Color
),ExprRef
) - symbolDashanyOf(List(float),
ExprRef
) - symbolDashOffsetanyOf(float,
ExprRef
) - symbolFillColoranyOf(anyOf(None,
Color
),ExprRef
) - symbolLimitanyOf(float,
ExprRef
) - symbolOffsetanyOf(float,
ExprRef
) - symbolOpacityanyOf(float,
ExprRef
) - symbolSizeanyOf(float,
ExprRef
) - symbolStrokeColoranyOf(anyOf(None,
Color
),ExprRef
) - symbolStrokeWidthanyOf(float,
ExprRef
) - symbolTypeanyOf(
SymbolShape
,ExprRef
) - tickCountanyOf(
TickCount
,ExprRef
) - tickMinStepanyOf(float,
ExprRef
) The minimum desired step between legend ticks, in terms of scale domain values. For example, a value of
1
indicates that ticks should not be less than 1 unit apart. IftickMinStep
is specified, thetickCount
value will be adjusted, if necessary, to enforce the minimum step value.Default value :
undefined
- titleanyOf(
Text
, None) A title for the field. If
null
, the title will be removed.Default value: derived from the field’s name and transformation function (
aggregate
,bin
andtimeUnit
). If the field has an aggregate function, the function is displayed as part of the title (e.g.,"Sum of Profit"
). If the field is binned or has a time unit applied, the applied function is shown in parentheses (e.g.,"Profit (binned)"
,"Transaction Date (year-month)"
). Otherwise, the title is simply the field name.Notes :
1) You can customize the default field title format by providing the fieldTitle property in the config or fieldTitle function via the compile function’s options.
2) If both field definition’s
title
and axis, header, or legendtitle
are defined, axis/header/legend title will be used.- titleAlignanyOf(
Align
,ExprRef
) - titleAnchoranyOf(
TitleAnchor
,ExprRef
) - titleBaselineanyOf(
TextBaseline
,ExprRef
) - titleColoranyOf(anyOf(None,
Color
),ExprRef
) - titleFontanyOf(string,
ExprRef
) - titleFontSizeanyOf(float,
ExprRef
) - titleFontStyleanyOf(
FontStyle
,ExprRef
) - titleFontWeightanyOf(
FontWeight
,ExprRef
) - titleLimitanyOf(float,
ExprRef
) - titleLineHeightanyOf(float,
ExprRef
) - titleOpacityanyOf(float,
ExprRef
) - titleOrientanyOf(
Orient
,ExprRef
) - titlePaddinganyOf(float,
ExprRef
) - typeenum(‘symbol’, ‘gradient’)
The type of the legend. Use
"symbol"
to create a discrete legend and"gradient"
for a continuous color gradient.Default value:
"gradient"
for non-binned quantitative fields and temporal fields;"symbol"
otherwise.- valuesanyOf(List(float), List(string), List(boolean), List(
DateTime
), - :class:`ExprRef`)
Explicitly set the visible legend values.
- zindexfloat
A non-negative integer indicating the z-index of the legend. If zindex is 0, legend should be drawn behind all chart elements. To put them in front, use zindex = 1.
- ariaanyOf(boolean,
- __init__(aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=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, type=Undefined, values=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