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:
color : anyOf(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 and stroke channels. The fill or stroke encodings have higher precedence than color, thus may override the color 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.

detail : anyOf(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 or column is specified, this channel will be ignored.

fill : anyOf(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 than color, thus may override the color encoding if conflicting encodings are specified.

fillOpacity : anyOf(NumericFieldDefWithCondition,
:class:`NumericValueWithCondition`)

Fill opacity of the marks.

Default value: If undefined, the default opacity depends on mark config ‘s fillOpacity property.

href : anyOf(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.

latitude : anyOf(LatLongFieldDef, NumberValueDef)

Latitude position of geographically projected marks.

latitude2 : anyOf(SecondaryFieldDef, NumberValueDef)

Latitude-2 position for geographically projected ranged "area", "bar", "rect", and "rule".

longitude : anyOf(LatLongFieldDef, NumberValueDef)

Longitude position of geographically projected marks.

longitude2 : anyOf(SecondaryFieldDef, NumberValueDef)

Longitude-2 position for geographically projected ranged "area", "bar", "rect", and "rule".

opacity : anyOf(NumericFieldDefWithCondition, NumericValueWithCondition)

Opacity of the marks.

Default value: If undefined, the default opacity depends on mark config ‘s opacity property.

order : anyOf(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. Setting order 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 be aggregate d to avoid creating additional aggregation grouping.

row : RowColumnEncodingFieldDef

A field definition for the vertical facet of trellis plots.

shape : anyOf(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 data

Default value: If undefined, the default shape depends on mark config ‘s shape property. ( "circle" if unset.)

size : anyOf(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)
stroke : anyOf(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 than color, thus may override the color encoding if conflicting encodings are specified.

strokeDash : anyOf(NumericArrayFieldDefWithCondition,
:class:`NumericArrayValueDefWithCondition`)

Stroke dash of the marks.

Default value: [1,0] (No dash).

strokeOpacity : anyOf(NumericFieldDefWithCondition,
:class:`NumericValueWithCondition`)

Stroke opacity of the marks.

Default value: If undefined, the default opacity depends on mark config ‘s strokeOpacity property.

strokeWidth : anyOf(NumericFieldDefWithCondition,
:class:`NumericValueWithCondition`)

Stroke width of the marks.

Default value: If undefined, the default stroke width depends on mark config ‘s strokeWidth property.

text : anyOf(TextFieldDefWithCondition, TextValueWithCondition)

Text of the text mark.

tooltip : anyOf(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.

url : anyOf(StringFieldDefWithCondition, StringValueWithCondition)

The URL of an image mark.

x : anyOf(PositionFieldDef, XValueDef)

X coordinates of the marks, or width of horizontal "bar" and "area" without specified x2 or width.

The value of this channel can be a number or a string "width" for the width of the plot.

x2 : anyOf(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.

xError : anyOf(SecondaryFieldDef, NumberValueDef)

Error value of x coordinates for error specified "errorbar" and "errorband".

xError2 : anyOf(SecondaryFieldDef, NumberValueDef)

Secondary error value of x coordinates for error specified "errorbar" and "errorband".

y : anyOf(PositionFieldDef, YValueDef)

Y coordinates of the marks, or height of vertical "bar" and "area" without specified y2 or height.

The value of this channel can be a number or a string "height" for the height of the plot.

y2 : anyOf(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.

yError : anyOf(SecondaryFieldDef, NumberValueDef)

Error value of y coordinates for error specified "errorbar" and "errorband".

yError2 : anyOf(SecondaryFieldDef, NumberValueDef)

Secondary error value of y coordinates for error specified "errorbar" and "errorband".

__init__(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)

Methods

__init__([color, column, detail, facet, …])
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
copy(deep=True, ignore=())

Return a copy of the object

Parameters:
deep : boolean 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.

ignore : list, optional

A list of keys for which the contents should not be copied, but only stored by reference.

from_dict(dct, validate=True, _wrapper_classes=None)

Construct class from a dictionary representation

Parameters:
dct : dictionary

The dict from which to construct the class

validate : boolean

If True (default), then validate the input against the schema.

_wrapper_classes : list (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:
obj : Schema object

The wrapped schema

Raises:
jsonschema.ValidationError :

if validate=True and dct does not conform to the schema

from_json(json_string, validate=True, **kwargs)

Instantiate the object from a valid JSON string

Parameters:
json_string : string

The string containing a valid JSON chart specification.

validate : boolean

If True (default), then validate the input against the schema.

**kwargs :

Additional keyword arguments are passed to json.loads

Returns:
chart : Chart object

The altair Chart object built from the specification.

resolve_references(schema=None)

Resolve references in the context of this object’s schema or root schema.

to_dict(validate=True, ignore=None, context=None)

Return a dictionary representation of the object

Parameters:
validate : boolean 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.

ignore : list

A list of keys to ignore. This will not passed to child to_dict function calls.

context : dict (optional)

A context dictionary that will be passed to all child to_dict function calls

Returns:
dct : dictionary

The dictionary representation of this object

Raises:
jsonschema.ValidationError :

if validate=True and the dict does not conform to the schema

to_json(validate=True, ignore=[], context={}, indent=2, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters:
validate : boolean 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.

ignore : list

A list of keys to ignore. This will not passed to child to_dict function calls.

context : dict (optional)

A context dictionary that will be passed to all child to_dict function calls

indent : integer, default 2

the number of spaces of indentation to use

sort_keys : boolean, default True

if True, sort keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns:
spec : string

The JSON specification of the chart object.

validate(instance, schema=None)

Validate the instance against the class schema in the context of the rootschema.

validate_property(name, value, schema=None)

Validate a property against property schema in the context of the rootschema