altair.FacetedEncoding¶
-
class
altair.
FacetedEncoding
(color=Undefined, column=Undefined, detail=Undefined, facet=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, row=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, **kwds)¶ FacetedEncoding schema wrapper
Mapping(required=[])
- Attributes
- coloranyOf(
ColorGradientFieldDefWithCondition
, - :class:`ColorGradientValueWithCondition`)
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.- column
RowColumnEncodingFieldDef
A field definition for the horizontal facet of trellis plots.
- detailanyOf(
FieldDefWithoutScale
, List(FieldDefWithoutScale
)) 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.
- facet
FacetEncodingFieldDef
A field definition for the (flexible) facet of trellis plots.
If either
row
orcolumn
is specified, this channel will be ignored.- fillanyOf(
ColorGradientFieldDefWithCondition
, - :class:`ColorGradientValueWithCondition`)
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.- fillOpacityanyOf(
NumericFieldDefWithCondition
, - :class:`NumericValueWithCondition`)
Fill opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
fillOpacity
property.- hrefanyOf(
StringFieldDefWithCondition
,StringValueWithCondition
) A URL to load upon mouse click.
- key
FieldDefWithoutScale
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.
- latitudeanyOf(
LatLongFieldDef
,NumberValueDef
) Latitude position of geographically projected marks.
- latitude2anyOf(
SecondaryFieldDef
,NumberValueDef
) Latitude-2 position for geographically projected ranged
"area"
,"bar"
,"rect"
, and"rule"
.- longitudeanyOf(
LatLongFieldDef
,NumberValueDef
) Longitude position of geographically projected marks.
- longitude2anyOf(
SecondaryFieldDef
,NumberValueDef
) Longitude-2 position for geographically projected ranged
"area"
,"bar"
,"rect"
, and"rule"
.- opacityanyOf(
NumericFieldDefWithCondition
,NumericValueWithCondition
) Opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
opacity
property.- orderanyOf(
OrderFieldDef
, List(OrderFieldDef
),NumberValueDef
) 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.- row
RowColumnEncodingFieldDef
A field definition for the vertical facet of trellis plots.
- shapeanyOf(
ShapeFieldDefWithCondition
,ShapeValueWithCondition
) 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.)- sizeanyOf(
NumericFieldDefWithCondition
,NumericValueWithCondition
) 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)
- strokeanyOf(
ColorGradientFieldDefWithCondition
, - :class:`ColorGradientValueWithCondition`)
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.- strokeDashanyOf(
NumericArrayFieldDefWithCondition
, - :class:`NumericArrayValueDefWithCondition`)
Stroke dash of the marks.
Default value:
[1,0]
(No dash).- strokeOpacityanyOf(
NumericFieldDefWithCondition
, - :class:`NumericValueWithCondition`)
Stroke opacity of the marks.
Default value: If undefined, the default opacity depends on mark config ‘s
strokeOpacity
property.- strokeWidthanyOf(
NumericFieldDefWithCondition
, - :class:`NumericValueWithCondition`)
Stroke width of the marks.
Default value: If undefined, the default stroke width depends on mark config ‘s
strokeWidth
property.- textanyOf(
TextFieldDefWithCondition
,TextValueWithCondition
) Text of the
text
mark.- tooltipanyOf(
StringFieldDefWithCondition
,StringValueWithCondition
, - List(:class:`StringFieldDef`), None)
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.
- urlanyOf(
StringFieldDefWithCondition
,StringValueWithCondition
) The URL of an image mark.
- xanyOf(
PositionFieldDef
,XValueDef
) 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.- x2anyOf(
SecondaryFieldDef
,XValueDef
) 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.- xErroranyOf(
SecondaryFieldDef
,NumberValueDef
) Error value of x coordinates for error specified
"errorbar"
and"errorband"
.- xError2anyOf(
SecondaryFieldDef
,NumberValueDef
) Secondary error value of x coordinates for error specified
"errorbar"
and"errorband"
.- yanyOf(
PositionFieldDef
,YValueDef
) 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.- y2anyOf(
SecondaryFieldDef
,YValueDef
) 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.- yErroranyOf(
SecondaryFieldDef
,NumberValueDef
) Error value of y coordinates for error specified
"errorbar"
and"errorband"
.- yError2anyOf(
SecondaryFieldDef
,NumberValueDef
) Secondary error value of y coordinates for error specified
"errorbar"
and"errorband"
.
- coloranyOf(
-
__init__
(self, color=Undefined, column=Undefined, detail=Undefined, facet=Undefined, fill=Undefined, fillOpacity=Undefined, href=Undefined, key=Undefined, latitude=Undefined, latitude2=Undefined, longitude=Undefined, longitude2=Undefined, opacity=Undefined, order=Undefined, row=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeDash=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, text=Undefined, tooltip=Undefined, url=Undefined, x=Undefined, x2=Undefined, xError=Undefined, xError2=Undefined, y=Undefined, y2=Undefined, yError=Undefined, yError2=Undefined, **kwds)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(self[, color, column, detail, …])Initialize self.
copy
(self[, 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
(self[, validate, ignore, context])Return a dictionary representation of the object
to_json
(self[, validate, ignore, context, …])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
-
copy
(self, deep=True, ignore=())¶ Return a copy of the object
- Parameters
- deepboolean or list, optional
If True (default) then return a deep copy of all dict, list, and SchemaBase objects within the object structure. If False, then only copy the top object. If a list or iterable, then only copy the listed attributes.
- ignorelist, optional
A list of keys for which the contents should not be copied, but only stored by reference.
-
classmethod
from_dict
(dct, validate=True, _wrapper_classes=None)¶ Construct class from a dictionary representation
- Parameters
- dctdictionary
The dict from which to construct the class
- validateboolean
If True (default), then validate the input against the schema.
- _wrapper_classeslist (optional)
The set of SchemaBase classes to use when constructing wrappers of the dict inputs. If not specified, the result of cls._default_wrapper_classes will be used.
- Returns
- objSchema object
The wrapped schema
- Raises
- jsonschema.ValidationError :
if validate=True and dct does not conform to the schema
-
classmethod
from_json
(json_string, validate=True, **kwargs)¶ Instantiate the object from a valid JSON string
- Parameters
- json_stringstring
The string containing a valid JSON chart specification.
- validateboolean
If True (default), then validate the input against the schema.
- **kwargs :
Additional keyword arguments are passed to json.loads
- Returns
- chartChart object
The altair Chart object built from the specification.
-
classmethod
resolve_references
(schema=None)¶ Resolve references in the context of this object’s schema or root schema.
-
to_dict
(self, validate=True, ignore=None, context=None)¶ Return a dictionary representation of the object
- Parameters
- validateboolean or string
If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.
- ignorelist
A list of keys to ignore. This will not passed to child to_dict function calls.
- contextdict (optional)
A context dictionary that will be passed to all child to_dict function calls
- Returns
- dctdictionary
The dictionary representation of this object
- Raises
- jsonschema.ValidationError :
if validate=True and the dict does not conform to the schema
-
to_json
(self, validate=True, ignore=[], context={}, indent=2, sort_keys=True, **kwargs)¶ Emit the JSON representation for this object as a string.
- Parameters
- validateboolean or string
If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.
- ignorelist
A list of keys to ignore. This will not passed to child to_dict function calls.
- contextdict (optional)
A context dictionary that will be passed to all child to_dict function calls
- indentinteger, default 2
the number of spaces of indentation to use
- sort_keysboolean, default True
if True, sort keys in the output
- **kwargs
Additional keyword arguments are passed to
json.dumps()
- Returns
- specstring
The JSON specification of the chart object.
-
classmethod
validate
(instance, schema=None)¶ Validate the instance against the class schema in the context of the rootschema.
-
classmethod
validate_property
(name, value, schema=None)¶ Validate a property against property schema in the context of the rootschema