altair.Encoding#
- class altair.Encoding(angle=Undefined, color=Undefined, description=Undefined, detail=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, radius=Undefined, radius2=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, theta=Undefined, theta2=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, xOffset=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, yOffset=Undefined, **kwds)#
Encoding schema wrapper
Encoding
, Dict- Parameters:
- angle
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Rotation angle of point and text marks.
- color
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
, Dict[required=[shorthand]],ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
, Dict Color of the marks – either fill or stroke color based on the
filled
property of mark definition. By default,color
represents fill color for"area"
,"bar"
,"tick"
,"text"
,"trail"
,"circle"
, and"square"
/ stroke color for"line"
and"point"
.Default value: If undefined, the default color depends on mark config ‘s
color
property.Note: 1) For fine-grained control over both fill and stroke colors of the marks, please use the
fill
andstroke
channels. Thefill
orstroke
encodings have higher precedence thancolor
, thus may override thecolor
encoding if conflicting encodings are specified. 2) See the scale documentation for more information about customizing color scheme.- description
StringFieldDefWithCondition
, Dict[required=[shorthand]],StringValueDefWithCondition
, Dict A text description of this mark for ARIA accessibility (SVG output only). For SVG output the
"aria-label"
attribute will be set to this description.- detail
FieldDefWithoutScale
, Dict[required=[shorthand]], Sequence[FieldDefWithoutScale
, Dict[required=[shorthand]]] Additional levels of detail for grouping data in aggregate views and in line, trail, and area marks without mapping data to a specific visual channel.
- fill
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
, Dict[required=[shorthand]],ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
, Dict Fill color of the marks. Default value: If undefined, the default color depends on mark config ‘s
color
property.Note: The
fill
encoding has higher precedence thancolor
, thus may override thecolor
encoding if conflicting encodings are specified.- fillOpacity
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Fill opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
fillOpacity
property.- href
StringFieldDefWithCondition
, Dict[required=[shorthand]],StringValueDefWithCondition
, Dict A URL to load upon mouse click.
- key
FieldDefWithoutScale
, Dict[required=[shorthand]] A data field to use as a unique key for data binding. When a visualization’s data is updated, the key value will be used to match data elements to existing mark instances. Use a key channel to enable object constancy for transitions over dynamic data.
- latitude
DatumDef
, Dict,LatLongDef
,LatLongFieldDef
, Dict[required=[shorthand]] Latitude position of geographically projected marks.
- latitude2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] Latitude-2 position for geographically projected ranged
"area"
,"bar"
,"rect"
, and"rule"
.- longitude
DatumDef
, Dict,LatLongDef
,LatLongFieldDef
, Dict[required=[shorthand]] Longitude position of geographically projected marks.
- longitude2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] Longitude-2 position for geographically projected ranged
"area"
,"bar"
,"rect"
, and"rule"
.- opacity
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
opacity
property.- order
OrderFieldDef
, Dict[required=[shorthand]],OrderOnlyDef
, Dict,OrderValueDef
, Dict[required=[value]], Sequence[OrderFieldDef
, Dict[required=[shorthand]]] Order of the marks.
For stacked marks, this
order
channel encodes stack order.For line and trail marks, this
order
channel encodes order of data points in the lines. This can be useful for creating a connected scatterplot. Settingorder
to{"value": null}
makes the line marks use the original order in the data sources.Otherwise, this
order
channel encodes layer order of the marks.
Note : In aggregate plots,
order
field should beaggregate
d to avoid creating additional aggregation grouping.- radius
PolarDef
,PositionDatumDefBase
, Dict,PositionFieldDefBase
, Dict[required=[shorthand]],PositionValueDef
, Dict[required=[value]] The outer radius in pixels of arc marks.
- radius2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] The inner radius in pixels of arc marks.
- shape
FieldOrDatumDefWithConditionDatumDefstringnull
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull
, Dict[required=[shorthand]],ShapeDef
,ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull
, Dict Shape of the mark.
#. For
point
marks the supported values include: - plotting shapes:"circle"
,"square"
,"cross"
,"diamond"
,"triangle-up"
,"triangle-down"
,"triangle-right"
, or"triangle-left"
. - the line symbol"stroke"
- centered directional shapes"arrow"
,"wedge"
, or"triangle"
- a custom SVG path string (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.)#. For
geoshape
marks it should be a field definition of the geojson dataDefault value: If undefined, the default shape depends on mark config ‘s
shape
property. ("circle"
if unset.)- size
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Size of the mark.
For
"point"
,"square"
and"circle"
, – the symbol size, or pixel area of the mark.For
"bar"
and"tick"
– the bar and tick’s size.For
"text"
– the text’s font size.Size is unsupported for
"line"
,"area"
, and"rect"
. (Use"trail"
instead of line with varying size)
- stroke
ColorDef
,FieldOrDatumDefWithConditionDatumDefGradientstringnull
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull
, Dict[required=[shorthand]],ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull
, Dict Stroke color of the marks. Default value: If undefined, the default color depends on mark config ‘s
color
property.Note: The
stroke
encoding has higher precedence thancolor
, thus may override thecolor
encoding if conflicting encodings are specified.- strokeDash
FieldOrDatumDefWithConditionDatumDefnumberArray
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray
, Dict[required=[shorthand]],NumericArrayMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray
, Dict Stroke dash of the marks.
Default value:
[1,0]
(No dash).- strokeOpacity
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Stroke opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
strokeOpacity
property.- strokeWidth
FieldOrDatumDefWithConditionDatumDefnumber
, Dict,FieldOrDatumDefWithConditionMarkPropFieldDefnumber
, Dict[required=[shorthand]],NumericMarkPropDef
,ValueDefWithConditionMarkPropFieldOrDatumDefnumber
, Dict Stroke width of the marks.
Default value: If undefined, the default stroke width depends on mark config ‘s
strokeWidth
property.- text
FieldOrDatumDefWithConditionStringDatumDefText
, Dict,FieldOrDatumDefWithConditionStringFieldDefText
, Dict[required=[shorthand]],TextDef
,ValueDefWithConditionStringFieldDefText
, Dict Text of the
text
mark.- theta
PolarDef
,PositionDatumDefBase
, Dict,PositionFieldDefBase
, Dict[required=[shorthand]],PositionValueDef
, Dict[required=[value]] For arc marks, the arc length in radians if theta2 is not specified, otherwise the start arc angle. (A value of 0 indicates up or “north”, increasing values proceed clockwise.)
For text marks, polar coordinate angle in radians.
- theta2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] The end angle of arc marks in radians. A value of 0 indicates up or “north”, increasing values proceed clockwise.
- tooltip
StringFieldDefWithCondition
, Dict[required=[shorthand]],StringValueDefWithCondition
, Dict, None, Sequence[StringFieldDef
, Dict] The tooltip text to show upon mouse hover. Specifying
tooltip
encoding overrides the tooltip property in the mark definition.See the tooltip documentation for a detailed discussion about tooltip in Vega-Lite.
- url
StringFieldDefWithCondition
, Dict[required=[shorthand]],StringValueDefWithCondition
, Dict The URL of an image mark.
- x
PositionDatumDef
, Dict,PositionDef
,PositionFieldDef
, Dict[required=[shorthand]],PositionValueDef
, Dict[required=[value]] X coordinates of the marks, or width of horizontal
"bar"
and"area"
without specifiedx2
orwidth
.The
value
of this channel can be a number or a string"width"
for the width of the plot.- x2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] X2 coordinates for ranged
"area"
,"bar"
,"rect"
, and"rule"
.The
value
of this channel can be a number or a string"width"
for the width of the plot.- xError
SecondaryFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Error value of x coordinates for error specified
"errorbar"
and"errorband"
.- xError2
SecondaryFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Secondary error value of x coordinates for error specified
"errorbar"
and"errorband"
.- xOffset
OffsetDef
,ScaleDatumDef
, Dict,ScaleFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Offset of x-position of the marks
- y
PositionDatumDef
, Dict,PositionDef
,PositionFieldDef
, Dict[required=[shorthand]],PositionValueDef
, Dict[required=[value]] Y coordinates of the marks, or height of vertical
"bar"
and"area"
without specifiedy2
orheight
.The
value
of this channel can be a number or a string"height"
for the height of the plot.- y2
DatumDef
, Dict,Position2Def
,PositionValueDef
, Dict[required=[value]],SecondaryFieldDef
, Dict[required=[shorthand]] Y2 coordinates for ranged
"area"
,"bar"
,"rect"
, and"rule"
.The
value
of this channel can be a number or a string"height"
for the height of the plot.- yError
SecondaryFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Error value of y coordinates for error specified
"errorbar"
and"errorband"
.- yError2
SecondaryFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Secondary error value of y coordinates for error specified
"errorbar"
and"errorband"
.- yOffset
OffsetDef
,ScaleDatumDef
, Dict,ScaleFieldDef
, Dict[required=[shorthand]],ValueDefnumber
, Dict[required=[value]] Offset of y-position of the marks
- angle
- __init__(angle=Undefined, color=Undefined, description=Undefined, detail=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, radius=Undefined, radius2=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, theta=Undefined, theta2=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, xOffset=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, yOffset=Undefined, **kwds)#
Methods
__init__
([angle, color, description, ...])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, indent, sort_keys, ...])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