API Reference

Top-Level Objects

class altair.Chart(**kwargs)
Trait Type Description
config Config Configuration object
description JSON string An optional description of this mark for commenting purpose. […]
encoding Encoding A key-value mapping between encoding channels and definition of […]
height JSON number
mark string The mark type. One of [‘area’, ‘bar’, ‘line’, ‘point’, ‘text’, ‘tick’, ‘rule’, ‘circle’, ‘square’, ‘errorBar’].
max_rows an int Maximum number of rows in the dataset to accept.
name JSON string Name of the visualization for later reference.
transform Transform An object describing filter and new field calculation.
validate_columns boolean Raise FieldError if the data is a DataFrame and there are missing columns.
width JSON number
clone()

Return a clone of this object, recursively cloning each trait

configure(axis=undefined, background=undefined, cell=undefined, countTitle=undefined, facet=undefined, legend=undefined, mark=undefined, numberFormat=undefined, overlay=undefined, scale=undefined, timeFormat=undefined, viewport=undefined, **kwargs)

Set chart configuration

Arguments are passed to Config.

configure_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the chart’s cell’s by keyword args.

Arguments are passed to CellConfig.

configure_facet(axis=undefined, cell=undefined, grid=undefined, scale=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

configure_facet_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_facet_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

configure_facet_grid(color=undefined, offset=undefined, opacity=undefined, **kwargs)

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

configure_facet_scale(padding=undefined, round=undefined, **kwargs)

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

configure_legend(gradientHeight=undefined, gradientStrokeColor=undefined, gradientStrokeWidth=undefined, gradientWidth=undefined, labelAlign=undefined, labelBaseline=undefined, labelColor=undefined, labelFont=undefined, labelFontSize=undefined, labelOffset=undefined, margin=undefined, offset=undefined, orient=undefined, padding=undefined, properties=undefined, shortTimeLabels=undefined, symbolColor=undefined, symbolShape=undefined, symbolSize=undefined, symbolStrokeWidth=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, **kwargs)

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

configure_mark(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

configure_overlay(area=undefined, line=undefined, lineStyle=undefined, pointStyle=undefined, **kwargs)

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

configure_scale(bandSize=undefined, barSizeRange=undefined, fontSizeRange=undefined, nominalColorRange=undefined, opacity=undefined, padding=undefined, pointSizeRange=undefined, round=undefined, ruleSizeRange=undefined, sequentialColorRange=undefined, shapeRange=undefined, textBandWidth=undefined, tickSizeRange=undefined, useRawDomain=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

display()

Display the Chart using the Jupyter Notebook’s rich output.

To use this is the classic Jupyter Notebook, the ipyvega package must be installed.

To use this in JupyterLab/nteract, run the enable_mime_rendering function first.

encode(color=undefined, column=undefined, detail=undefined, label=undefined, opacity=undefined, order=undefined, path=undefined, row=undefined, shape=undefined, size=undefined, text=undefined, x=undefined, x2=undefined, y=undefined, y2=undefined, **kwargs)

Define the encoding for the Chart.

Arguments are passed to Encoding.

classmethod from_dict(spec)
from_json(json_string, **kwargs)

Instantiate the object from a valid JSON string

Parameters:

spec : string

The string containing a valid JSON chart specification.

Returns:

chart : Chart object

The altair Chart object built from the specification.

classmethod load_example(name)

Load an example chart

Initialize a chart object from one of the built-in examples

Parameters:

example : string

The example ID or filename, e.g. "line" or "line.json"

Returns:

chart : Chart, LayeredChart, or FacetedChart

The Chart object containing the example

mark_area(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘area’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_bar(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘bar’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_circle(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘circle’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_errorBar(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘errorBar’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_line(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘line’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_point(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘point’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_rule(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘rule’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_square(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘square’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_text(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘text’ and optionally specify mark properties

Arguments are passed to MarkConfig.

mark_tick(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Set the mark to ‘tick’ and optionally specify mark properties

Arguments are passed to MarkConfig.

register_converters(**kwargs)
savechart(outfile, filetype=None)

Save a chart to file, in either png, svg, json, or html format.

Note that png/svg output requires several nodejs packages to be installed and correctly configured. Before running this, you must have nodejs and cairo on your system and use the node package manager to install the canvas and vega-lite packages.

If you are using anaconda, you can set it up this way:

$ conda create -n node-env -c conda-forge python=2.7 cairo nodejs altair $ source activate node-env $ npm install canvas vega-lite

The node binaries used here (vl2vg, vl2png, vl2svg) will be installed in the node root directory, which should be automatically detected by this function.

Parameters:

outfile : str

The output filename

filetype : str (optional)

The filetype to use. One of (‘svg’, ‘png’, ‘json’, ‘html’). If not specified, it will be inferred from outfile.

serve(ip='127.0.0.1', port=8888, n_retries=50, files=None, jupyter_warning=True, open_browser=True, http_server=None, **html_kwargs)

Open a web browser and visualize the chart

Parameters:

html : string

HTML to serve

ip : string (default = ‘127.0.0.1’)

ip address at which the HTML will be served.

port : int (default = 8888)

the port at which to serve the HTML

n_retries : int (default = 50)

the number of nearby ports to search if the specified port is already in use.

files : dictionary (optional)

dictionary of extra content to serve

jupyter_warning : bool (optional)

if True (default), then print a warning if this is used within the Jupyter notebook

open_browser : bool (optional)

if True (default), then open a web browser to the given HTML

http_server : class (optional)

optionally specify an HTTPServer class to use for showing the figure. The default is Python’s basic HTTPServer.

to_altair(data=None)

DEPRECATED. Use to_python() instead.

Emit the Python code as a string required to created this Chart.

to_dict(data=True, validate_columns=False)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

If True (default) then include data in the representation.

validate_columns : bool

If True (default is False) raise FieldError if there are missing or misspelled column names. This only actually raises if self.validate_columns is also set (it defaults to True).

Returns:

spec : dict

The JSON specification of the chart object.

to_html(template=None, title=None, **kwargs)

Emit a stand-alone HTML document containing this chart.

Parameters:

template : string

The HTML template to use. This should have a format method, which accepts a “spec” and “title” argument. Note that a standard Python format string meets these requirements. By default, uses altair.utils.html.DEFAULT_TEMPLATE.

title : string

The title to use in the document. Default is “Vega-Lite Chart”

kwargs :

additional keywords to be passed to the template

Returns:

html : string

A string of HTML representing the chart

See also

savechart
save a chart representation to file in various formats, including HTML
to_json(data=True, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters:

data : bool

If True (default) then include data in the representation.

sort_keys : bool

If True (default) then sort the keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns:

spec : string

The JSON specification of the chart object.

to_python(data=None)

Emit the Python code as a string required to created this Chart.

transform_data(calculate=undefined, filter=undefined, filterInvalid=undefined, **kwargs)

Set the data transform by keyword args.

Arguments are passed to Transform.

data
class altair.LayeredChart(**kwargs)
Trait Type Description
config Config Configuration object
description JSON string An optional description of this mark for commenting purpose. […]
height JSON number
layers list of Chart Unit specs that will be layered.
max_rows an int Maximum number of rows in the dataset to accept.
name JSON string Name of the visualization for later reference.
transform Transform An object describing filter and new field calculation.
validate_columns boolean Raise FieldError if the data is a DataFrame and there are missing columns.
width JSON number
clone()

Return a clone of this object, recursively cloning each trait

configure(axis=undefined, background=undefined, cell=undefined, countTitle=undefined, facet=undefined, legend=undefined, mark=undefined, numberFormat=undefined, overlay=undefined, scale=undefined, timeFormat=undefined, viewport=undefined, **kwargs)

Set chart configuration

Arguments are passed to Config.

configure_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the chart’s cell’s by keyword args.

Arguments are passed to CellConfig.

configure_facet(axis=undefined, cell=undefined, grid=undefined, scale=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

configure_facet_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_facet_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

configure_facet_grid(color=undefined, offset=undefined, opacity=undefined, **kwargs)

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

configure_facet_scale(padding=undefined, round=undefined, **kwargs)

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

configure_legend(gradientHeight=undefined, gradientStrokeColor=undefined, gradientStrokeWidth=undefined, gradientWidth=undefined, labelAlign=undefined, labelBaseline=undefined, labelColor=undefined, labelFont=undefined, labelFontSize=undefined, labelOffset=undefined, margin=undefined, offset=undefined, orient=undefined, padding=undefined, properties=undefined, shortTimeLabels=undefined, symbolColor=undefined, symbolShape=undefined, symbolSize=undefined, symbolStrokeWidth=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, **kwargs)

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

configure_mark(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

configure_overlay(area=undefined, line=undefined, lineStyle=undefined, pointStyle=undefined, **kwargs)

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

configure_scale(bandSize=undefined, barSizeRange=undefined, fontSizeRange=undefined, nominalColorRange=undefined, opacity=undefined, padding=undefined, pointSizeRange=undefined, round=undefined, ruleSizeRange=undefined, sequentialColorRange=undefined, shapeRange=undefined, textBandWidth=undefined, tickSizeRange=undefined, useRawDomain=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

display()

Display the Chart using the Jupyter Notebook’s rich output.

To use this is the classic Jupyter Notebook, the ipyvega package must be installed.

To use this in JupyterLab/nteract, run the enable_mime_rendering function first.

from_dict(dct)

Instantiate the object from a valid JSON dictionary

Parameters:

dct : dict

The dictionary containing a valid JSON chart specification.

Returns:

chart : Chart object

The altair Chart object built from the specification.

from_json(json_string, **kwargs)

Instantiate the object from a valid JSON string

Parameters:

spec : string

The string containing a valid JSON chart specification.

Returns:

chart : Chart object

The altair Chart object built from the specification.

register_converters(**kwargs)
savechart(outfile, filetype=None)

Save a chart to file, in either png, svg, json, or html format.

Note that png/svg output requires several nodejs packages to be installed and correctly configured. Before running this, you must have nodejs and cairo on your system and use the node package manager to install the canvas and vega-lite packages.

If you are using anaconda, you can set it up this way:

$ conda create -n node-env -c conda-forge python=2.7 cairo nodejs altair $ source activate node-env $ npm install canvas vega-lite

The node binaries used here (vl2vg, vl2png, vl2svg) will be installed in the node root directory, which should be automatically detected by this function.

Parameters:

outfile : str

The output filename

filetype : str (optional)

The filetype to use. One of (‘svg’, ‘png’, ‘json’, ‘html’). If not specified, it will be inferred from outfile.

serve(ip='127.0.0.1', port=8888, n_retries=50, files=None, jupyter_warning=True, open_browser=True, http_server=None, **html_kwargs)

Open a web browser and visualize the chart

Parameters:

html : string

HTML to serve

ip : string (default = ‘127.0.0.1’)

ip address at which the HTML will be served.

port : int (default = 8888)

the port at which to serve the HTML

n_retries : int (default = 50)

the number of nearby ports to search if the specified port is already in use.

files : dictionary (optional)

dictionary of extra content to serve

jupyter_warning : bool (optional)

if True (default), then print a warning if this is used within the Jupyter notebook

open_browser : bool (optional)

if True (default), then open a web browser to the given HTML

http_server : class (optional)

optionally specify an HTTPServer class to use for showing the figure. The default is Python’s basic HTTPServer.

set_layers(*layers)
to_altair(data=None)

DEPRECATED. Use to_python() instead.

Emit the Python code as a string required to created this Chart.

to_dict(data=True, validate_columns=False)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

If True (default) then include data in the representation.

validate_columns : bool

If True (default is False) raise FieldError if there are missing or misspelled column names. This only actually raises if self.validate_columns is also set (it defaults to True).

Returns:

spec : dict

The JSON specification of the chart object.

to_html(template=None, title=None, **kwargs)

Emit a stand-alone HTML document containing this chart.

Parameters:

template : string

The HTML template to use. This should have a format method, which accepts a “spec” and “title” argument. Note that a standard Python format string meets these requirements. By default, uses altair.utils.html.DEFAULT_TEMPLATE.

title : string

The title to use in the document. Default is “Vega-Lite Chart”

kwargs :

additional keywords to be passed to the template

Returns:

html : string

A string of HTML representing the chart

See also

savechart
save a chart representation to file in various formats, including HTML
to_json(data=True, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters:

data : bool

If True (default) then include data in the representation.

sort_keys : bool

If True (default) then sort the keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns:

spec : string

The JSON specification of the chart object.

to_python(data=None)

Emit the Python code as a string required to created this Chart.

transform_data(calculate=undefined, filter=undefined, filterInvalid=undefined, **kwargs)

Set the data transform by keyword args.

Arguments are passed to Transform.

data
class altair.FacetedChart(**kwargs)
Trait Type Description
config Config Configuration object
description JSON string An optional description of this mark for commenting purpose. […]
facet Facet
max_rows an int Maximum number of rows in the dataset to accept.
name JSON string Name of the visualization for later reference.
spec LayeredChart or Chart
transform Transform An object describing filter and new field calculation.
validate_columns boolean Raise FieldError if the data is a DataFrame and there are missing columns.
clone()

Return a clone of this object, recursively cloning each trait

configure(axis=undefined, background=undefined, cell=undefined, countTitle=undefined, facet=undefined, legend=undefined, mark=undefined, numberFormat=undefined, overlay=undefined, scale=undefined, timeFormat=undefined, viewport=undefined, **kwargs)

Set chart configuration

Arguments are passed to Config.

configure_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the chart’s cell’s by keyword args.

Arguments are passed to CellConfig.

configure_facet(axis=undefined, cell=undefined, grid=undefined, scale=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

configure_facet_axis(axisColor=undefined, axisWidth=undefined, characterWidth=undefined, grid=undefined, gridColor=undefined, gridDash=undefined, gridOpacity=undefined, gridWidth=undefined, labelAlign=undefined, labelAngle=undefined, labelBaseline=undefined, labelMaxLength=undefined, labels=undefined, layer=undefined, offset=undefined, properties=undefined, shortTimeLabels=undefined, subdivide=undefined, tickColor=undefined, tickLabelColor=undefined, tickLabelFont=undefined, tickLabelFontSize=undefined, tickPadding=undefined, tickSize=undefined, tickSizeEnd=undefined, tickSizeMajor=undefined, tickSizeMinor=undefined, tickWidth=undefined, ticks=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, titleMaxLength=undefined, titleOffset=undefined, **kwargs)

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

configure_facet_cell(clip=undefined, fill=undefined, fillOpacity=undefined, height=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, width=undefined, **kwargs)

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

configure_facet_grid(color=undefined, offset=undefined, opacity=undefined, **kwargs)

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

configure_facet_scale(padding=undefined, round=undefined, **kwargs)

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

configure_legend(gradientHeight=undefined, gradientStrokeColor=undefined, gradientStrokeWidth=undefined, gradientWidth=undefined, labelAlign=undefined, labelBaseline=undefined, labelColor=undefined, labelFont=undefined, labelFontSize=undefined, labelOffset=undefined, margin=undefined, offset=undefined, orient=undefined, padding=undefined, properties=undefined, shortTimeLabels=undefined, symbolColor=undefined, symbolShape=undefined, symbolSize=undefined, symbolStrokeWidth=undefined, titleColor=undefined, titleFont=undefined, titleFontSize=undefined, titleFontWeight=undefined, **kwargs)

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

configure_mark(align=undefined, angle=undefined, applyColorToBackground=undefined, barSize=undefined, barThinSize=undefined, baseline=undefined, color=undefined, dx=undefined, dy=undefined, fill=undefined, fillOpacity=undefined, filled=undefined, font=undefined, fontSize=undefined, fontStyle=undefined, fontWeight=undefined, format=undefined, interpolate=undefined, lineSize=undefined, opacity=undefined, orient=undefined, radius=undefined, ruleSize=undefined, shape=undefined, shortTimeLabels=undefined, size=undefined, stacked=undefined, stroke=undefined, strokeDash=undefined, strokeDashOffset=undefined, strokeOpacity=undefined, strokeWidth=undefined, tension=undefined, text=undefined, theta=undefined, tickSize=undefined, tickThickness=undefined, **kwargs)

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

configure_overlay(area=undefined, line=undefined, lineStyle=undefined, pointStyle=undefined, **kwargs)

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

configure_scale(bandSize=undefined, barSizeRange=undefined, fontSizeRange=undefined, nominalColorRange=undefined, opacity=undefined, padding=undefined, pointSizeRange=undefined, round=undefined, ruleSizeRange=undefined, sequentialColorRange=undefined, shapeRange=undefined, textBandWidth=undefined, tickSizeRange=undefined, useRawDomain=undefined, **kwargs)

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

display()

Display the Chart using the Jupyter Notebook’s rich output.

To use this is the classic Jupyter Notebook, the ipyvega package must be installed.

To use this in JupyterLab/nteract, run the enable_mime_rendering function first.

from_dict(dct)

Instantiate the object from a valid JSON dictionary

Parameters:

dct : dict

The dictionary containing a valid JSON chart specification.

Returns:

chart : Chart object

The altair Chart object built from the specification.

from_json(json_string, **kwargs)

Instantiate the object from a valid JSON string

Parameters:

spec : string

The string containing a valid JSON chart specification.

Returns:

chart : Chart object

The altair Chart object built from the specification.

register_converters(**kwargs)
savechart(outfile, filetype=None)

Save a chart to file, in either png, svg, json, or html format.

Note that png/svg output requires several nodejs packages to be installed and correctly configured. Before running this, you must have nodejs and cairo on your system and use the node package manager to install the canvas and vega-lite packages.

If you are using anaconda, you can set it up this way:

$ conda create -n node-env -c conda-forge python=2.7 cairo nodejs altair $ source activate node-env $ npm install canvas vega-lite

The node binaries used here (vl2vg, vl2png, vl2svg) will be installed in the node root directory, which should be automatically detected by this function.

Parameters:

outfile : str

The output filename

filetype : str (optional)

The filetype to use. One of (‘svg’, ‘png’, ‘json’, ‘html’). If not specified, it will be inferred from outfile.

serve(ip='127.0.0.1', port=8888, n_retries=50, files=None, jupyter_warning=True, open_browser=True, http_server=None, **html_kwargs)

Open a web browser and visualize the chart

Parameters:

html : string

HTML to serve

ip : string (default = ‘127.0.0.1’)

ip address at which the HTML will be served.

port : int (default = 8888)

the port at which to serve the HTML

n_retries : int (default = 50)

the number of nearby ports to search if the specified port is already in use.

files : dictionary (optional)

dictionary of extra content to serve

jupyter_warning : bool (optional)

if True (default), then print a warning if this is used within the Jupyter notebook

open_browser : bool (optional)

if True (default), then open a web browser to the given HTML

http_server : class (optional)

optionally specify an HTTPServer class to use for showing the figure. The default is Python’s basic HTTPServer.

set_facet(column=undefined, row=undefined, **kwargs)

Define the facet encoding for the Chart.

Arguments are passed to Facet.

to_altair(data=None)

DEPRECATED. Use to_python() instead.

Emit the Python code as a string required to created this Chart.

to_dict(data=True, validate_columns=False)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

If True (default) then include data in the representation.

validate_columns : bool

If True (default is False) raise FieldError if there are missing or misspelled column names. This only actually raises if self.validate_columns is also set (it defaults to True).

Returns:

spec : dict

The JSON specification of the chart object.

to_html(template=None, title=None, **kwargs)

Emit a stand-alone HTML document containing this chart.

Parameters:

template : string

The HTML template to use. This should have a format method, which accepts a “spec” and “title” argument. Note that a standard Python format string meets these requirements. By default, uses altair.utils.html.DEFAULT_TEMPLATE.

title : string

The title to use in the document. Default is “Vega-Lite Chart”

kwargs :

additional keywords to be passed to the template

Returns:

html : string

A string of HTML representing the chart

See also

savechart
save a chart representation to file in various formats, including HTML
to_json(data=True, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters:

data : bool

If True (default) then include data in the representation.

sort_keys : bool

If True (default) then sort the keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns:

spec : string

The JSON specification of the chart object.

to_python(data=None)

Emit the Python code as a string required to created this Chart.

transform_data(calculate=undefined, filter=undefined, filterInvalid=undefined, **kwargs)

Set the data transform by keyword args.

Arguments are passed to Transform.

data

Encoding Collections

class altair.Encoding(**kwargs)

Object for storing channel encodings

(See also Vega-Lite’s Documentation for Encoding)

Trait Type Description
color Color Color of the marks – either fill or stroke color based on mark […]
column Column Horizontal facets for trellis plots.
detail Detail or list of Detail Additional levels of detail for grouping data in aggregate views […]
label Label
opacity Opacity Opacity of the marks – either can be a value or in a range.
order Order or list of Order Layer order for non-stacked marks, or stack order for stacked marks.
path Path or list of Path Order of data points in line marks.
row Row Vertical facets for trellis plots.
shape Shape The symbol’s shape (only for point marks). The supported […]
size Size Size of the mark. - For point, square and circle – the […]
text Text Text of the text mark.
x X X coordinates for point, circle, square, line, rule, […]
x2 X2 X2 coordinates for ranged bar, rule, area
y Y Y coordinates for point, circle, square, line, rule, […]
y2 Y2 Y2 coordinates for ranged bar, rule, area
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
channel_names = ['color', 'column', 'detail', 'label', 'opacity', 'order', 'path', 'row', 'shape', 'size', 'text', 'x', 'x2', 'y', 'y2']
class altair.Facet(**kwargs)

Object for storing channel encodings

Trait Type Description
column Column
row Row
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
channel_names = ['column', 'row']

Encoding Channels

class altair.Color(**kwargs)

(See also Vega-Lite’s Documentation for Color)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Column(**kwargs)

(See also Vega-Lite’s Documentation for Column)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis JSON boolean or Axis
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Detail(**kwargs)

(See also Vega-Lite’s Documentation for Detail)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Label(**kwargs)
Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Opacity(**kwargs)

(See also Vega-Lite’s Documentation for Opacity)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Order(**kwargs)

(See also Vega-Lite’s Documentation for Order)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Path(**kwargs)

(See also Vega-Lite’s Documentation for Path)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Row(**kwargs)

(See also Vega-Lite’s Documentation for Row)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis JSON boolean or Axis
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Shape(**kwargs)

(See also Vega-Lite’s Documentation for Shape)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Size(**kwargs)

(See also Vega-Lite’s Documentation for Size)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Text(**kwargs)

(See also Vega-Lite’s Documentation for Text)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.X(**kwargs)

(See also Vega-Lite’s Documentation for X)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis JSON boolean or Axis
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)
class altair.Y(**kwargs)

(See also Vega-Lite’s Documentation for Y)

Trait Type Description
aggregate string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis JSON boolean or Axis
bin JSON boolean or Bin Flag for binning a quantitative field, or a bin property […]
field JSON string Name of the field from which to pull a data value.
scale Scale
shorthand JSON string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort SortField or string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
title JSON string Title for axis or legend.
type string One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value JSON number or JSON string or JSON boolean A constant value in visual domain.
clone()

Return a clone of this object, recursively cloning each trait

from_dict(dct, **kwargs)

Initialize an instance from a (nested) dictionary

from_json(json_string, json_kwds=None, **kwargs)

Instantiate object from a JSON string

register_converters(**kwargs)
to_dict(**kwargs)

Output a (nested) dict encoding the contents of this instance

to_json(json_kwds=None, **kwargs)

Output the object’s representation to a JSON string

to_python(**kwargs)

Other Objects

exception altair.FieldError

Raised if a channel has a field related error.

This is raised if a channel has no field name or if the field name is not found as the column name of the DataFrame.

exception altair.MaxRowsExceeded

Raised if the number of rows in the dataset is too large.

class altair.Axis(**kwargs)

Axis class

(See also Vega-Lite’s Documentation for Axis)

Trait Type Description
axisColor JSON string Color of axis line.
axisWidth JSON number Width of the axis line
characterWidth JSON number Character width for automatically determining title max length.
format JSON string The formatting pattern for axis labels.
grid JSON boolean A flag indicate if gridlines should be created in addition to […]
gridColor JSON string Color of gridlines.
gridDash list of JSON number The offset (in pixels) into which to begin drawing with the grid […]
gridOpacity JSON number The stroke opacity of grid (value between [0,1])
gridWidth JSON number The grid width, in pixels.
labelAlign JSON string Text alignment for the Label.
labelAngle JSON number The rotation angle of the axis labels.
labelBaseline JSON string Text baseline for the label.
labelMaxLength JSON number Truncate labels that are too long.
labels JSON boolean Enable or disable labels.
layer JSON string A string indicating if the axis (and any gridlines) should be […]
offset JSON number The offset, in pixels, by which to displace the axis from the […]
orient string One of [‘top’, ‘right’, ‘left’, ‘bottom’].
properties Mapping Optional mark property definitions for custom axis styling.
shortTimeLabels JSON boolean Whether month and day names should be abbreviated.
subdivide JSON number If provided, sets the number of minor ticks between major ticks […]
tickColor JSON string The color of the axis’s tick.
tickLabelColor JSON string The color of the tick label, can be in hex color code or regular […]
tickLabelFont JSON string The font of the tick label.
tickLabelFontSize JSON number The font size of label, in pixels.
tickPadding JSON number The padding, in pixels, between ticks and text labels.
tickSize JSON number The size, in pixels, of major, minor and end ticks.
tickSizeEnd JSON number The size, in pixels, of end ticks.
tickSizeMajor JSON number The size, in pixels, of major ticks.
tickSizeMinor JSON number The size, in pixels, of minor ticks.
tickWidth JSON number The width, in pixels, of ticks.
ticks JSON number A desired number of ticks, for axes visualizing quantitative […]
title JSON string A title for the axis. Shows field name and its function by default.
titleColor JSON string Color of the title, can be in hex color code or regular color name.
titleFont JSON string Font of the title.
titleFontSize JSON number Size of the title.
titleFontWeight JSON string Weight of the title.
titleMaxLength JSON number Max length for axis title if the title is automatically […]
titleOffset JSON number A title offset value for the axis.
values list of JSON number or list of DateTime
axisColor

A trait whose value is a JSON string

axisWidth

A trait whose value is a JSON Number

characterWidth

A trait whose value is a JSON Number

format

A trait whose value is a JSON string

grid

A trait whose value is a JSON boolean value

gridColor

A trait whose value is a JSON string

gridDash

A trait whose value is an array of typed items

gridOpacity

A trait whose value is a JSON Number

gridWidth

A trait whose value is a JSON Number

labelAlign

A trait whose value is a JSON string

labelAngle

A trait whose value is a JSON Number

labelBaseline

A trait whose value is a JSON string

labelMaxLength

A trait whose value is a JSON Number

labels

A trait whose value is a JSON boolean value

layer

A trait whose value is a JSON string

offset

A trait whose value is a JSON Number

orient

One of [‘top’, ‘right’, ‘left’, ‘bottom’]

properties

A trait whose value is an instance of a class

shortTimeLabels

A trait whose value is a JSON boolean value

subdivide

A trait whose value is a JSON Number

tickColor

A trait whose value is a JSON string

tickLabelColor

A trait whose value is a JSON string

tickLabelFont

A trait whose value is a JSON string

tickLabelFontSize

A trait whose value is a JSON Number

tickPadding

A trait whose value is a JSON Number

tickSize

A trait whose value is a JSON Number

tickSizeEnd

A trait whose value is a JSON Number

tickSizeMajor

A trait whose value is a JSON Number

tickSizeMinor

A trait whose value is a JSON Number

tickWidth

A trait whose value is a JSON Number

ticks

A trait whose value is a JSON Number

title

A trait whose value is a JSON string

titleColor

A trait whose value is a JSON string

titleFont

A trait whose value is a JSON string

titleFontSize

A trait whose value is a JSON Number

titleFontWeight

A trait whose value is a JSON string

titleMaxLength

A trait whose value is a JSON Number

titleOffset

A trait whose value is a JSON Number

values

A trait whose value matches any of a list of traits

class altair.AxisConfig(**kwargs)

AxisConfig class

(See also Vega-Lite’s Documentation for AxisConfig)

Trait Type Description
axisColor JSON string Color of axis line.
axisWidth JSON number Width of the axis line
characterWidth JSON number Character width for automatically determining title max length.
grid JSON boolean A flag indicate if gridlines should be created in addition to […]
gridColor JSON string Color of gridlines.
gridDash list of JSON number The offset (in pixels) into which to begin drawing with the grid […]
gridOpacity JSON number The stroke opacity of grid (value between [0,1])
gridWidth JSON number The grid width, in pixels.
labelAlign JSON string Text alignment for the Label.
labelAngle JSON number The rotation angle of the axis labels.
labelBaseline JSON string Text baseline for the label.
labelMaxLength JSON number Truncate labels that are too long.
labels JSON boolean Enable or disable labels.
layer JSON string A string indicating if the axis (and any gridlines) should be […]
offset JSON number The offset, in pixels, by which to displace the axis from the […]
properties Mapping Optional mark property definitions for custom axis styling.
shortTimeLabels JSON boolean Whether month and day names should be abbreviated.
subdivide JSON number If provided, sets the number of minor ticks between major ticks […]
tickColor JSON string The color of the axis’s tick.
tickLabelColor JSON string The color of the tick label, can be in hex color code or regular […]
tickLabelFont JSON string The font of the tick label.
tickLabelFontSize JSON number The font size of label, in pixels.
tickPadding JSON number The padding, in pixels, between ticks and text labels.
tickSize JSON number The size, in pixels, of major, minor and end ticks.
tickSizeEnd JSON number The size, in pixels, of end ticks.
tickSizeMajor JSON number The size, in pixels, of major ticks.
tickSizeMinor JSON number The size, in pixels, of minor ticks.
tickWidth JSON number The width, in pixels, of ticks.
ticks JSON number A desired number of ticks, for axes visualizing quantitative […]
titleColor JSON string Color of the title, can be in hex color code or regular color name.
titleFont JSON string Font of the title.
titleFontSize JSON number Size of the title.
titleFontWeight JSON string Weight of the title.
titleMaxLength JSON number Max length for axis title if the title is automatically […]
titleOffset JSON number A title offset value for the axis.
axisColor

A trait whose value is a JSON string

axisWidth

A trait whose value is a JSON Number

characterWidth

A trait whose value is a JSON Number

grid

A trait whose value is a JSON boolean value

gridColor

A trait whose value is a JSON string

gridDash

A trait whose value is an array of typed items

gridOpacity

A trait whose value is a JSON Number

gridWidth

A trait whose value is a JSON Number

labelAlign

A trait whose value is a JSON string

labelAngle

A trait whose value is a JSON Number

labelBaseline

A trait whose value is a JSON string

labelMaxLength

A trait whose value is a JSON Number

labels

A trait whose value is a JSON boolean value

layer

A trait whose value is a JSON string

offset

A trait whose value is a JSON Number

properties

A trait whose value is an instance of a class

shortTimeLabels

A trait whose value is a JSON boolean value

subdivide

A trait whose value is a JSON Number

tickColor

A trait whose value is a JSON string

tickLabelColor

A trait whose value is a JSON string

tickLabelFont

A trait whose value is a JSON string

tickLabelFontSize

A trait whose value is a JSON Number

tickPadding

A trait whose value is a JSON Number

tickSize

A trait whose value is a JSON Number

tickSizeEnd

A trait whose value is a JSON Number

tickSizeMajor

A trait whose value is a JSON Number

tickSizeMinor

A trait whose value is a JSON Number

tickWidth

A trait whose value is a JSON Number

ticks

A trait whose value is a JSON Number

titleColor

A trait whose value is a JSON string

titleFont

A trait whose value is a JSON string

titleFontSize

A trait whose value is a JSON Number

titleFontWeight

A trait whose value is a JSON string

titleMaxLength

A trait whose value is a JSON Number

titleOffset

A trait whose value is a JSON Number

class altair.Bin(**kwargs)

Bin class

(See also Vega-Lite’s Documentation for Bin)

Trait Type Description
base JSON number The number base to use for automatic bin determination (default […]
div list of JSON number Scale factors indicating allowable subdivisions. The default […]
max JSON number The maximum bin value to consider. If unspecified, the maximum […]
maxbins JSON number Maximum number of bins.
min JSON number The minimum bin value to consider. If unspecified, the minimum […]
minstep JSON number A minimum allowable step size (particularly useful for integer […]
step JSON number An exact step size to use between bins. If provided, options […]
steps list of JSON number An array of allowable step sizes to choose from.
base

A trait whose value is a JSON Number

div

A trait whose value is an array of typed items

max

A trait whose value is a JSON Number

maxbins

A trait whose value is a JSON Number

min

A trait whose value is a JSON Number

minstep

A trait whose value is a JSON Number

step

A trait whose value is a JSON Number

steps

A trait whose value is an array of typed items

class altair.CellConfig(**kwargs)

CellConfig class

(See also Vega-Lite’s Documentation for CellConfig)

Trait Type Description
clip JSON boolean
fill JSON string The fill color.
fillOpacity JSON number The fill opacity (value between [0,1]).
height JSON number
stroke JSON string The stroke color.
strokeDash list of JSON number An array of alternating stroke, space lengths for creating […]
strokeDashOffset JSON number The offset (in pixels) into which to begin drawing with the […]
strokeOpacity JSON number The stroke opacity (value between [0,1]).
strokeWidth JSON number The stroke width, in pixels.
width JSON number
clip

A trait whose value is a JSON boolean value

fill

A trait whose value is a JSON string

fillOpacity

A trait whose value is a JSON Number

height

A trait whose value is a JSON Number

stroke

A trait whose value is a JSON string

strokeDash

A trait whose value is an array of typed items

strokeDashOffset

A trait whose value is a JSON Number

strokeOpacity

A trait whose value is a JSON Number

strokeWidth

A trait whose value is a JSON Number

width

A trait whose value is a JSON Number

class altair.Config(**kwargs)

Config class

(See also Vega-Lite’s Documentation for Config)

Trait Type Description
axis AxisConfig Axis Config
background JSON string CSS color property to use as background of visualization. […]
cell CellConfig Cell Config
countTitle JSON string Default axis and legend title for count fields.
facet FacetConfig Facet Config
legend LegendConfig Legend Config
mark MarkConfig Mark Config
numberFormat JSON string D3 Number format for axis labels and text tables. For example […]
overlay OverlayConfig Mark Overlay Config
scale ScaleConfig Scale Config
timeFormat JSON string Default datetime format for axis and legend labels. The format […]
viewport JSON number The width and height of the on-screen viewport, in pixels. If […]
axis

A trait whose value is an instance of a class

background

A trait whose value is a JSON string

cell

A trait whose value is an instance of a class

countTitle

A trait whose value is a JSON string

facet

A trait whose value is an instance of a class

legend

A trait whose value is an instance of a class

mark

A trait whose value is an instance of a class

numberFormat

A trait whose value is a JSON string

overlay

A trait whose value is an instance of a class

scale

A trait whose value is an instance of a class

timeFormat

A trait whose value is a JSON string

viewport

A trait whose value is a JSON Number

class altair.Data(**kwargs)

Data class

(See also Vega-Lite’s Documentation for Data)

Trait Type Description
format DataFormat An object that specifies the format for the data file or values.
url JSON string A URL from which to load the data set. Use the format.type […]
values list of any value Pass array of objects instead of a url to a file.
format

A trait whose value is an instance of a class

url

A trait whose value is a JSON string

values

A trait whose value is an array of typed items

class altair.DataFormat(**kwargs)

DataFormat class

Trait Type Description
feature JSON string The name of the TopoJSON object set to convert to a GeoJSON […]
mesh JSON string The name of the TopoJSON object set to convert to a mesh. […]
parse Mapping A collection of parsing instructions can be used to define the […]
property JSON string JSON only) The JSON property containing the desired data. This […]
type string One of [‘json’, ‘csv’, ‘tsv’, ‘topojson’].
feature

A trait whose value is a JSON string

mesh

A trait whose value is a JSON string

parse

A trait whose value is an instance of a class

property

A trait whose value is a JSON string

type

One of [‘json’, ‘csv’, ‘tsv’, ‘topojson’]

class altair.DateTime(**kwargs)

DateTime class

Trait Type Description
date JSON number Integer value representing the date from 1-31.
day JSON number or JSON string Value representing the day of week. This can be one of: (1) […]
hours JSON number Integer value representing the hour of day from 0-23.
milliseconds JSON number Integer value representing millisecond segment of a time.
minutes JSON number Integer value representing minute segment of a time from 0-59.
month JSON number or JSON string One of: (1) integer value representing the month from 1-12. […]
quarter JSON number Integer value representing the quarter of the year (from 1-4).
seconds JSON number Integer value representing second segment of a time from 0-59.
year JSON number Integer value representing the year.
date

A trait whose value is a JSON Number

day

A trait whose value matches one of a list of trait types

hours

A trait whose value is a JSON Number

milliseconds

A trait whose value is a JSON Number

minutes

A trait whose value is a JSON Number

month

A trait whose value matches one of a list of trait types

quarter

A trait whose value is a JSON Number

seconds

A trait whose value is a JSON Number

year

A trait whose value is a JSON Number

class altair.EqualFilter(**kwargs)

EqualFilter class

Trait Type Description
equal JSON string or JSON number or JSON boolean or DateTime Value that the field should be equal to.
field JSON string Field to be filtered.
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
equal

A trait whose value matches any of a list of traits

field

A trait whose value is a JSON string

timeUnit

One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’]

class altair.FacetConfig(**kwargs)

FacetConfig class

(See also Vega-Lite’s Documentation for FacetConfig)

Trait Type Description
axis AxisConfig Facet Axis Config
cell CellConfig Facet Cell Config
grid FacetGridConfig Facet Grid Config
scale FacetScaleConfig Facet Scale Config
axis

A trait whose value is an instance of a class

cell

A trait whose value is an instance of a class

grid

A trait whose value is an instance of a class

scale

A trait whose value is an instance of a class

class altair.FacetGridConfig(**kwargs)

FacetGridConfig class

Trait Type Description
color JSON string
offset JSON number
opacity JSON number
color

A trait whose value is a JSON string

offset

A trait whose value is a JSON Number

opacity

A trait whose value is a JSON Number

class altair.FacetScaleConfig(**kwargs)

FacetScaleConfig class

Trait Type Description
padding JSON number
round JSON boolean
padding

A trait whose value is a JSON Number

round

A trait whose value is a JSON boolean value

class altair.Formula(**kwargs)
Trait Type Description
expr JSON string or an Expression A string containing an expression for the formula. Use the […]
field JSON string The field in which to store the computed formula value.
expr

A trait whose value matches one of a list of trait types

class altair.Legend(**kwargs)

Legend class

(See also Vega-Lite’s Documentation for Legend)

Trait Type Description
format JSON string An optional formatting pattern for legend labels. Vega uses […]
gradientHeight JSON number The height of the gradient, in pixels.
gradientStrokeColor JSON string The color of the gradient stroke, can be in hex color code or […]
gradientStrokeWidth JSON number The width of the gradient stroke, in pixels.
gradientWidth JSON number The width of the gradient, in pixels.
labelAlign JSON string The alignment of the legend label, can be left, middle or right.
labelBaseline JSON string The position of the baseline of legend label, can be top, middle […]
labelColor JSON string The color of the legend label, can be in hex color code or […]
labelFont JSON string The font of the legend label.
labelFontSize JSON number The font size of legend label.
labelOffset JSON number The offset of the legend label.
margin JSON number The margin around the legend, in pixels
offset JSON number The offset, in pixels, by which to displace the legend from the […]
orient JSON string The orientation of the legend. One of “left” or “right”. This […]
padding JSON number The padding, in pixels, between the legend and axis.
properties Mapping Optional mark property definitions for custom legend styling.
shortTimeLabels JSON boolean Whether month names and weekday names should be abbreviated.
symbolColor JSON string The color of the legend symbol,
symbolShape JSON string The shape of the legend symbol, can be the ‘circle’, ‘square’, […]
symbolSize JSON number The size of the legend symbol, in pixels.
symbolStrokeWidth JSON number The width of the symbol’s stroke.
title JSON string A title for the legend. (Shows field name and its function by […]
titleColor JSON string Optional mark property definitions for custom legend styling. […]
titleFont JSON string The font of the legend title.
titleFontSize JSON number The font size of the legend title.
titleFontWeight JSON string The font weight of the legend title.
values list of JSON number or list of JSON string or list of DateTime Explicitly set the visible legend values.
format

A trait whose value is a JSON string

gradientHeight

A trait whose value is a JSON Number

gradientStrokeColor

A trait whose value is a JSON string

gradientStrokeWidth

A trait whose value is a JSON Number

gradientWidth

A trait whose value is a JSON Number

labelAlign

A trait whose value is a JSON string

labelBaseline

A trait whose value is a JSON string

labelColor

A trait whose value is a JSON string

labelFont

A trait whose value is a JSON string

labelFontSize

A trait whose value is a JSON Number

labelOffset

A trait whose value is a JSON Number

margin

A trait whose value is a JSON Number

offset

A trait whose value is a JSON Number

orient

A trait whose value is a JSON string

padding

A trait whose value is a JSON Number

properties

A trait whose value is an instance of a class

shortTimeLabels

A trait whose value is a JSON boolean value

symbolColor

A trait whose value is a JSON string

symbolShape

A trait whose value is a JSON string

symbolSize

A trait whose value is a JSON Number

symbolStrokeWidth

A trait whose value is a JSON Number

title

A trait whose value is a JSON string

titleColor

A trait whose value is a JSON string

titleFont

A trait whose value is a JSON string

titleFontSize

A trait whose value is a JSON Number

titleFontWeight

A trait whose value is a JSON string

values

A trait whose value matches any of a list of traits

class altair.LegendConfig(**kwargs)

LegendConfig class

(See also Vega-Lite’s Documentation for LegendConfig)

Trait Type Description
gradientHeight JSON number The height of the gradient, in pixels.
gradientStrokeColor JSON string The color of the gradient stroke, can be in hex color code or […]
gradientStrokeWidth JSON number The width of the gradient stroke, in pixels.
gradientWidth JSON number The width of the gradient, in pixels.
labelAlign JSON string The alignment of the legend label, can be left, middle or right.
labelBaseline JSON string The position of the baseline of legend label, can be top, middle […]
labelColor JSON string The color of the legend label, can be in hex color code or […]
labelFont JSON string The font of the legend label.
labelFontSize JSON number The font size of legend label.
labelOffset JSON number The offset of the legend label.
margin JSON number The margin around the legend, in pixels
offset JSON number The offset, in pixels, by which to displace the legend from the […]
orient JSON string The orientation of the legend. One of “left” or “right”. This […]
padding JSON number The padding, in pixels, between the legend and axis.
properties Mapping Optional mark property definitions for custom legend styling.
shortTimeLabels JSON boolean Whether month names and weekday names should be abbreviated.
symbolColor JSON string The color of the legend symbol,
symbolShape JSON string The shape of the legend symbol, can be the ‘circle’, ‘square’, […]
symbolSize JSON number The size of the legend symbol, in pixels.
symbolStrokeWidth JSON number The width of the symbol’s stroke.
titleColor JSON string Optional mark property definitions for custom legend styling. […]
titleFont JSON string The font of the legend title.
titleFontSize JSON number The font size of the legend title.
titleFontWeight JSON string The font weight of the legend title.
gradientHeight

A trait whose value is a JSON Number

gradientStrokeColor

A trait whose value is a JSON string

gradientStrokeWidth

A trait whose value is a JSON Number

gradientWidth

A trait whose value is a JSON Number

labelAlign

A trait whose value is a JSON string

labelBaseline

A trait whose value is a JSON string

labelColor

A trait whose value is a JSON string

labelFont

A trait whose value is a JSON string

labelFontSize

A trait whose value is a JSON Number

labelOffset

A trait whose value is a JSON Number

margin

A trait whose value is a JSON Number

offset

A trait whose value is a JSON Number

orient

A trait whose value is a JSON string

padding

A trait whose value is a JSON Number

properties

A trait whose value is an instance of a class

shortTimeLabels

A trait whose value is a JSON boolean value

symbolColor

A trait whose value is a JSON string

symbolShape

A trait whose value is a JSON string

symbolSize

A trait whose value is a JSON Number

symbolStrokeWidth

A trait whose value is a JSON Number

titleColor

A trait whose value is a JSON string

titleFont

A trait whose value is a JSON string

titleFontSize

A trait whose value is a JSON Number

titleFontWeight

A trait whose value is a JSON string

class altair.MarkConfig(**kwargs)

MarkConfig class

(See also Vega-Lite’s Documentation for MarkConfig)

Trait Type Description
align string One of [‘left’, ‘right’, ‘center’].
angle JSON number The rotation angle of the text, in degrees.
applyColorToBackground JSON boolean Apply color field to background color instead of the text.
barSize JSON number The size of the bars. If unspecified, the default size is […]
barThinSize JSON number The size of the bars on continuous scales.
baseline string One of [‘top’, ‘middle’, ‘bottom’].
color JSON string Default color.
dx JSON number The horizontal offset, in pixels, between the text label and its […]
dy JSON number The vertical offset, in pixels, between the text label and its […]
fill JSON string Default Fill Color. This has higher precedence than config.color
fillOpacity JSON number
filled JSON boolean Whether the shape’s color should be used as fill color instead […]
font JSON string The typeface to set the text in (e.g., Helvetica Neue).
fontSize JSON number The font size, in pixels.
fontStyle string One of [‘normal’, ‘italic’].
fontWeight string One of [‘normal’, ‘bold’].
format JSON string The formatting pattern for text value. If not defined, this will […]
interpolate string One of [‘linear’, ‘linear-closed’, ‘step’, ‘step-before’, ‘step-after’, ‘basis’, ‘basis-open’, ‘basis-closed’, ‘cardinal’, ‘cardinal-open’, ‘cardinal-closed’, ‘bundle’, ‘monotone’].
lineSize JSON number Size of line mark.
opacity JSON number
orient string One of [‘horizontal’, ‘vertical’].
radius JSON number Polar coordinate radial offset, in pixels, of the text label […]
ruleSize JSON number Size of rule mark.
shape string or JSON string The symbol shape to use. One of circle (default), square, cross, […] One of [‘circle’, ‘square’, ‘cross’, ‘diamond’, ‘triangle-up’, ‘triangle-down’].
shortTimeLabels JSON boolean Whether month names and weekday names should be abbreviated.
size JSON number The pixel area each the point. For example: in the case of […]
stacked string One of [‘zero’, ‘center’, ‘normalize’, ‘none’].
stroke JSON string Default Stroke Color. This has higher precedence than config.color
strokeDash list of JSON number An array of alternating stroke, space lengths for creating […]
strokeDashOffset JSON number The offset (in pixels) into which to begin drawing with the […]
strokeOpacity JSON number
strokeWidth JSON number
tension JSON number Depending on the interpolation type, sets the tension parameter.
text JSON string Placeholder Text
theta JSON number Polar coordinate angle, in radians, of the text label from the […]
tickSize JSON number The width of the ticks.
tickThickness JSON number Thickness of the tick mark.
align

One of [‘left’, ‘right’, ‘center’]

angle

A trait whose value is a JSON Number

applyColorToBackground

A trait whose value is a JSON boolean value

barSize

A trait whose value is a JSON Number

barThinSize

A trait whose value is a JSON Number

baseline

One of [‘top’, ‘middle’, ‘bottom’]

color

A trait whose value is a JSON string

dx

A trait whose value is a JSON Number

dy

A trait whose value is a JSON Number

fill

A trait whose value is a JSON string

fillOpacity

A trait whose value is a JSON Number

filled

A trait whose value is a JSON boolean value

font

A trait whose value is a JSON string

fontSize

A trait whose value is a JSON Number

fontStyle

One of [‘normal’, ‘italic’]

fontWeight

One of [‘normal’, ‘bold’]

format

A trait whose value is a JSON string

interpolate

One of [‘linear’, ‘linear-closed’, ‘step’, ‘step-before’, ‘step-after’, ‘basis’, ‘basis-open’, ‘basis-closed’, ‘cardinal’, ‘cardinal-open’, ‘cardinal-closed’, ‘bundle’, ‘monotone’]

lineSize

A trait whose value is a JSON Number

opacity

A trait whose value is a JSON Number

orient

One of [‘horizontal’, ‘vertical’]

radius

A trait whose value is a JSON Number

ruleSize

A trait whose value is a JSON Number

shape

A trait whose value matches any of a list of traits

shortTimeLabels

A trait whose value is a JSON boolean value

size

A trait whose value is a JSON Number

stacked

One of [‘zero’, ‘center’, ‘normalize’, ‘none’]

stroke

A trait whose value is a JSON string

strokeDash

A trait whose value is an array of typed items

strokeDashOffset

A trait whose value is a JSON Number

strokeOpacity

A trait whose value is a JSON Number

strokeWidth

A trait whose value is a JSON Number

tension

A trait whose value is a JSON Number

text

A trait whose value is a JSON string

theta

A trait whose value is a JSON Number

tickSize

A trait whose value is a JSON Number

tickThickness

A trait whose value is a JSON Number

class altair.OneOfFilter(**kwargs)

OneOfFilter class

Trait Type Description
field JSON string Field to be filtered
oneOf list of JSON string or JSON number or JSON boolean or DateTime A set of values that the field’s value should be a member of, […]
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
field

A trait whose value is a JSON string

oneOf

A trait whose value is an array of typed items

timeUnit

One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’]

class altair.RangeFilter(**kwargs)

RangeFilter class

Trait Type Description
field JSON string Field to be filtered
range list of JSON number or DateTime Array of inclusive minimum and maximum values for a field value […]
timeUnit string One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
field

A trait whose value is a JSON string

range

A trait whose value is an array of typed items

timeUnit

One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’]

class altair.Scale(**kwargs)

Scale class

(See also Vega-Lite’s Documentation for Scale)

Trait Type Description
bandSize JSON number or string One of [‘fit’].
clamp JSON boolean If true, values that exceed the data domain are clamped to […]
domain list of JSON number or list of JSON string or list of DateTime The domain of the scale, representing the set of data values. […]
exponent JSON number Sets the exponent of the scale transformation. For pow scale […]
nice JSON boolean or string If specified, modifies the scale domain to use a more human- […] One of [‘second’, ‘minute’, ‘hour’, ‘day’, ‘week’, ‘month’, ‘year’].
padding JSON number Applies spacing among ordinal elements in the scale range. The […]
range JSON string or list of JSON number or list of JSON string The range of the scale, representing the set of visual values. […]
round JSON boolean If true, rounds numeric output values to integers. This can be […]
type string One of [‘linear’, ‘log’, ‘pow’, ‘sqrt’, ‘quantile’, ‘quantize’, ‘ordinal’, ‘time’, ‘utc’].
useRawDomain JSON boolean Uses the source data range as scale domain instead of aggregated […]
zero JSON boolean If true, ensures that a zero baseline value is included in the […]
bandSize

A trait whose value matches any of a list of traits

clamp

A trait whose value is a JSON boolean value

domain

A trait whose value matches any of a list of traits

exponent

A trait whose value is a JSON Number

nice

A trait whose value matches any of a list of traits

padding

A trait whose value is a JSON Number

range

A trait whose value matches any of a list of traits

round

A trait whose value is a JSON boolean value

type

One of [‘linear’, ‘log’, ‘pow’, ‘sqrt’, ‘quantile’, ‘quantize’, ‘ordinal’, ‘time’, ‘utc’]

useRawDomain

A trait whose value is a JSON boolean value

zero

A trait whose value is a JSON boolean value

class altair.ScaleConfig(**kwargs)

ScaleConfig class

(See also Vega-Lite’s Documentation for ScaleConfig)

Trait Type Description
bandSize JSON number or string Default band size for (1) y ordinal scale, and (2) x ordinal […] One of [‘fit’].
barSizeRange list of JSON number Default range for bar size scale
fontSizeRange list of JSON number Default range for font size scale
nominalColorRange JSON string or list of JSON string Default range for nominal color scale
opacity list of JSON number Default range for opacity.
padding JSON number Default padding for x and y ordinal scales.
pointSizeRange list of JSON number Default range for bar size scale
round JSON boolean If true, rounds numeric output values to integers. This can be […]
ruleSizeRange list of JSON number Default range for rule stroke widths
sequentialColorRange JSON string or list of JSON string Default range for ordinal / continuous color scale
shapeRange JSON string or list of JSON string Default range for shape
textBandWidth JSON number Default band width for x ordinal scale when is mark is text.
tickSizeRange list of JSON number Default range for tick spans
useRawDomain JSON boolean Uses the source data range as scale domain instead of aggregated […]
bandSize

A trait whose value matches any of a list of traits

barSizeRange

A trait whose value is an array of typed items

fontSizeRange

A trait whose value is an array of typed items

nominalColorRange

A trait whose value matches any of a list of traits

opacity

A trait whose value is an array of typed items

padding

A trait whose value is a JSON Number

pointSizeRange

A trait whose value is an array of typed items

round

A trait whose value is a JSON boolean value

ruleSizeRange

A trait whose value is an array of typed items

sequentialColorRange

A trait whose value matches any of a list of traits

shapeRange

A trait whose value matches any of a list of traits

textBandWidth

A trait whose value is a JSON Number

tickSizeRange

A trait whose value is an array of typed items

useRawDomain

A trait whose value is a JSON boolean value

class altair.SortField(**kwargs)

SortField class

Trait Type Description
field JSON string The field name to aggregate over.
op string One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
order string One of [‘ascending’, ‘descending’, ‘none’].
field

A trait whose value is a JSON string

op

One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’]

order

One of [‘ascending’, ‘descending’, ‘none’]

class altair.Transform(**kwargs)

(See also Vega-Lite’s Documentation for Transform)

Trait Type Description
calculate list of Formula Calculate new field(s) using the provided expresssion(s). […]
filter JSON string or an Expression or EqualFilter or RangeFilter or OneOfFilter or list of JSON string or an Expression or EqualFilter or RangeFilter or OneOfFilter A string containing the filter Vega expression. Use datum to […]
filterInvalid JSON boolean Whether to filter invalid values (null and NaN) from the […]
filter

A trait whose value matches one of a list of trait types

class altair.Vega(spec=None, data=None, url=None, filename=None)

A display class for displaying Vega visualizations in the Jupyter frontends.

Vega expects a spec (a JSON-able dict) and data (dict) argument not already-serialized JSON strings. Scalar types (None, number, string) are not allowed, only dict containers.

reload()

Reload the raw spec from file or URL.

data

Return the data.

spec

Return the spec.

class altair.VegaLite(spec=None, data=None, url=None, filename=None)

A display class for displaying Vega-Lite visualizations in the Jupyter frontends.

Vega-Lite expects a spec (a JSON-able dict) and data (dict) argument not already-serialized JSON strings. Scalar types (None, number, string) are not allowed, only dict containers.

altair.disable_mime_rendering()

Disable MIME bundle based rendering used in JupyterLab/nteract.

altair.enable_mime_rendering()

Enable MIME bundle based rendering used in JupyterLab/nteract.

altair.list_datasets()

List the available datasets.

altair.tutorial(overwrite=False)

Copy the Altair tutorial notebooks into ./AltairTutorial and show a link in the notebook.

altair.load_dataset

Load a dataset by name as a pandas.DataFrame.