API Reference

Top-Level Objects

class altair.Chart(**kwargs)
Trait Type Description
config Config Configuration object.
description string An optional description of this mark for commenting purpose.
encoding Encoding A key-value mapping between encoding channels and definition of fields.
height float
mark string The mark type. One of [‘area’, ‘bar’, ‘line’, ‘point’, ‘text’, ‘tick’, ‘rule’, ‘circle’, ‘square’, ‘errorBar’].
name string Name of the visualization for later reference.
transform Transform An object describing filter and new field calculation.
width float
configure(axis=None, background=None, cell=None, countTitle=None, facet=None, legend=None, mark=None, numberFormat=None, overlay=None, scale=None, timeFormat=None, viewport=None, **kwargs)

Set chart configuration

Arguments are passed to Config.

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

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

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

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

Arguments are passed to CellConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

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

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

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

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

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

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

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

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

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

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

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

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

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

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

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

Define the encoding for the Chart.

Arguments are passed to Encoding.

classmethod from_dict(spec)
from_json(spec)

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=None, angle=None, applyColorToBackground=None, barSize=None, barThinSize=None, baseline=None, color=None, dx=None, dy=None, fill=None, fillOpacity=None, filled=None, font=None, fontSize=None, fontStyle=None, fontWeight=None, format=None, interpolate=None, lineSize=None, opacity=None, orient=None, radius=None, ruleSize=None, shape=None, shortTimeLabels=None, size=None, stacked=None, stroke=None, strokeDash=None, strokeDashOffset=None, strokeOpacity=None, strokeWidth=None, tension=None, text=None, theta=None, tickSize=None, tickThickness=None, **kwargs)

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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

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

Arguments are passed to MarkConfig.

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)

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

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

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

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.

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

Set the data transform by keyword args.

Arguments are passed to Transform.

class altair.LayeredChart(**kwargs)
Trait Type Description
config Config Configuration object.
description string An optional description of this mark for commenting purpose.
height float
layers list of Chart Unit specs that will be layered.
name string Name of the visualization for later reference.
transform Transform An object describing filter and new field calculation.
width float
configure(axis=None, background=None, cell=None, countTitle=None, facet=None, legend=None, mark=None, numberFormat=None, overlay=None, scale=None, timeFormat=None, viewport=None, **kwargs)

Set chart configuration

Arguments are passed to Config.

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

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

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

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

Arguments are passed to CellConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

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

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

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

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

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

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

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

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

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

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

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

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

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

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

display()
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(spec)

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.

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)

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

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

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

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.

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

Set the data transform by keyword args.

Arguments are passed to Transform.

class altair.FacetedChart(**kwargs)
Trait Type Description
config Config Configuration object.
description string An optional description of this mark for commenting purpose.
facet Facet
name string Name of the visualization for later reference.
spec LayeredChart or Chart
transform Transform An object describing filter and new field calculation.
configure(axis=None, background=None, cell=None, countTitle=None, facet=None, legend=None, mark=None, numberFormat=None, overlay=None, scale=None, timeFormat=None, viewport=None, **kwargs)

Set chart configuration

Arguments are passed to Config.

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

Configure the chart’s axes by keyword args.

Arguments are passed to AxisConfig.

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

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

Arguments are passed to CellConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to FacetConfig.

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

Configure the facet’s axes by keyword args.

Arguments are passed to AxisConfig.

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

Configure the facet’s cells by keyword args.

Arguments are passed to CellConfig.

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

Configure the facet’s grid by keyword args.

Arguments are passed to FacetGridConfig.

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

Configure the facet’s scales by keyword args.

Arguments are passed to FacetScaleConfig.

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

Configure the chart’s legend by keyword args.

Arguments are passed to LegendConfig.

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

Configure the chart’s marks by keyword args.

Arguments are passed to MarkConfig.

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

Configure the chart’s overlay by keyword args.

Arguments are passed to OverlayConfig.

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

Configure the chart’s scales by keyword args.

Arguments are passed to ScaleConfig.

display()
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(spec)

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.

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=None, row=None, **kwargs)

Define the facet encoding for the Chart.

Arguments are passed to Facet.

to_altair(data=None)

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

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

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

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.

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

Set the data transform by keyword args.

Arguments are passed to Transform.

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 type.
column Column Horizontal facets for trellis plots.
detail Detail or list of Detail
label Label
opacity Opacity Opacity of the marks - either can be a value or in a range.
order Order or list of Order
path Path or list of Path
row Row Vertical facets for trellis plots.
shape Shape The symbol’s shape (only for point marks).
size Size Size of the mark.
text Text Text of the text mark.
x X X coordinates for point, circle, square, line, rule, text, and tick (or to width and height for bar and area marks).
x2 X2 X2 coordinates for ranged bar, rule, area.
y Y Y coordinates for point, circle, square, line, rule, text, and tick (or to width and height for bar and area marks).
y2 Y2 Y2 coordinates for ranged bar, rule, area.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Facet(**kwargs)

Object for storing channel encodings

Trait Type Description
column Column
row Row
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

Encoding Channels

class altair.Color(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Column(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis boolean or Axis
bin boolean or Bin
field string Name of the field from which to pull a data value.
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Detail(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
shorthand string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Label(**kwargs)
Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
shorthand string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Opacity(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Order(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
shorthand string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Path(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
shorthand string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
sort string One of [‘ascending’, ‘descending’, ‘none’].
timeUnit string Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Row(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis boolean or Axis
bin boolean or Bin
field string Name of the field from which to pull a data value.
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Shape(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Size(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
legend Legend
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Text(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
bin boolean or Bin
field string Name of the field from which to pull a data value.
shorthand string Shorthand specification of field, optionally including the aggregate and type (see Encoding Shorthands)
timeUnit string Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.X(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis boolean or Axis
bin boolean or Bin
field string Name of the field from which to pull a data value.
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Y(**kwargs)

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

Trait Type Description
aggregate string Aggregation function for the field . One of [‘values’, ‘count’, ‘valid’, ‘missing’, ‘distinct’, ‘sum’, ‘mean’, ‘average’, ‘variance’, ‘variancep’, ‘stdev’, ‘stdevp’, ‘median’, ‘q1’, ‘q3’, ‘modeskew’, ‘min’, ‘max’, ‘argmin’, ‘argmax’].
axis boolean or Axis
bin boolean or Bin
field string Name of the field from which to pull a data value.
scale Scale
shorthand 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 Time unit for a temporal field . 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 string Title for axis or legend.
type string The encoded field’s type of measurement. One of [‘quantitative’, ‘ordinal’, ‘temporal’, ‘nominal’].
value float or string or boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

Other Objects

class altair.Axis(**kwargs)

Wrapper for Vega-Lite Axis definition.

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

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

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.AxisConfig(**kwargs)

Wrapper for Vega-Lite AxisConfig definition.

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

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

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Bin(**kwargs)

Wrapper for Vega-Lite Bin definition.

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

Trait Type Description
base float The number base to use for automatic bin determination (default is base 10).
div list of float Scale factors indicating allowable subdivisions.
max float The maximum bin value to consider.
maxbins float Maximum number of bins.
min float The minimum bin value to consider.
minstep float A minimum allowable step size (particularly useful for integer values).
step float An exact step size to use between bins.
steps list of float An array of allowable step sizes to choose from.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.CellConfig(**kwargs)

Wrapper for Vega-Lite CellConfig definition.

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

Trait Type Description
clip boolean
fill string The fill color.
fillOpacity float The fill opacity (value between [0,1]).
height float
stroke string The stroke color.
strokeDash list of float An array of alternating stroke, space lengths for creating dashed or dotted lines.
strokeDashOffset float The offset (in pixels) into which to begin drawing with the stroke dash array.
strokeOpacity float The stroke opacity (value between [0,1]).
strokeWidth float The stroke width, in pixels.
width float
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Config(**kwargs)

Wrapper for Vega-Lite Config definition.

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

Trait Type Description
axis AxisConfig Axis Config.
background string CSS color property to use as background of visualization.
cell CellConfig Cell Config.
countTitle string Default axis and legend title for count fields.
facet FacetConfig Facet Config.
legend LegendConfig Legend Config.
mark MarkConfig Mark Config.
numberFormat string D3 Number format for axis labels and text tables.
overlay OverlayConfig Mark Overlay Config.
scale ScaleConfig Scale Config.
timeFormat string Default datetime format for axis and legend labels.
viewport float The width and height of the on-screen viewport, in pixels.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Data(**kwargs)

Wrapper for Vega-Lite Data definition.

(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 string A URL from which to load the data set.
values list of any value Pass array of objects instead of a url to a file.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.DataFormat(**kwargs)

Wrapper for Vega-Lite DataFormat definition.

Trait Type Description
feature string The name of the TopoJSON object set to convert to a GeoJSON feature collection.
mesh string The name of the TopoJSON object set to convert to a mesh.
parse any value A collection of parsing instructions can be used to define the data types of string-valued attributes in the JSON file.
property string JSON only) The JSON property containing the desired data.
type string Type of input data: “json”, “csv”, “tsv”. One of [‘json’, ‘csv’, ‘tsv’, ‘topojson’].
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.DateTime(**kwargs)

Wrapper for Vega-Lite DateTime definition.

Trait Type Description
date float Integer value representing the date from 1-31.
day float or string
hours float Integer value representing the hour of day from 0-23.
milliseconds float Integer value representing millisecond segment of a time.
minutes float Integer value representing minute segment of a time from 0-59.
month float or string
quarter float Integer value representing the quarter of the year (from 1-4).
seconds float Integer value representing second segment of a time from 0-59.
year float Integer value representing the year.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.EqualFilter(**kwargs)

Wrapper for Vega-Lite EqualFilter definition.

Trait Type Description
equal string or float or boolean or DateTime
field string Field to be filtered.
timeUnit string Time unit for the field to be filtered. One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.FacetConfig(**kwargs)

Wrapper for Vega-Lite FacetConfig definition.

(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.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.FacetGridConfig(**kwargs)

Wrapper for Vega-Lite FacetGridConfig definition.

Trait Type Description
color string
offset float
opacity float
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.FacetScaleConfig(**kwargs)

Wrapper for Vega-Lite FacetScaleConfig definition.

Trait Type Description
padding float
round boolean
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Formula(**kwargs)
Trait Type Description
expr string or an Expression A string containing an expression for the formula.
field string The field in which to store the computed formula value.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Legend(**kwargs)

Wrapper for Vega-Lite Legend definition.

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

Trait Type Description
format string An optional formatting pattern for legend labels.
gradientHeight float The height of the gradient, in pixels.
gradientStrokeColor string The color of the gradient stroke, can be in hex color code or regular color name.
gradientStrokeWidth float The width of the gradient stroke, in pixels.
gradientWidth float The width of the gradient, in pixels.
labelAlign string The alignment of the legend label, can be left, middle or right.
labelBaseline string The position of the baseline of legend label, can be top, middle or bottom.
labelColor string The color of the legend label, can be in hex color code or regular color name.
labelFont string The font of the legend label.
labelFontSize float The font size of legend label.
labelOffset float The offset of the legend label.
margin float The margin around the legend, in pixels.
offset float The offset, in pixels, by which to displace the legend from the edge of the enclosing group or data rectangle.
orient string The orientation of the legend.
padding float The padding, in pixels, between the legend and axis.
properties any value Optional mark property definitions for custom legend styling.
shortTimeLabels boolean Whether month names and weekday names should be abbreviated.
symbolColor string The color of the legend symbol,.
symbolShape string The shape of the legend symbol, can be the ‘circle’, ‘square’, ‘cross’, ‘diamond’, ‘triangle-up’, ‘triangle-down’, or else a custom SVG path string.
symbolSize float The size of the legend symbol, in pixels.
symbolStrokeWidth float The width of the symbol’s stroke.
title string A title for the legend.
titleColor string Optional mark property definitions for custom legend styling.
titleFont string The font of the legend title.
titleFontSize float The font size of the legend title.
titleFontWeight string The font weight of the legend title.
values list of float or list of string or list of DateTime
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.LegendConfig(**kwargs)

Wrapper for Vega-Lite LegendConfig definition.

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

Trait Type Description
gradientHeight float The height of the gradient, in pixels.
gradientStrokeColor string The color of the gradient stroke, can be in hex color code or regular color name.
gradientStrokeWidth float The width of the gradient stroke, in pixels.
gradientWidth float The width of the gradient, in pixels.
labelAlign string The alignment of the legend label, can be left, middle or right.
labelBaseline string The position of the baseline of legend label, can be top, middle or bottom.
labelColor string The color of the legend label, can be in hex color code or regular color name.
labelFont string The font of the legend label.
labelFontSize float The font size of legend label.
labelOffset float The offset of the legend label.
margin float The margin around the legend, in pixels.
offset float The offset, in pixels, by which to displace the legend from the edge of the enclosing group or data rectangle.
orient string The orientation of the legend.
padding float The padding, in pixels, between the legend and axis.
properties any value Optional mark property definitions for custom legend styling.
shortTimeLabels boolean Whether month names and weekday names should be abbreviated.
symbolColor string The color of the legend symbol,.
symbolShape string The shape of the legend symbol, can be the ‘circle’, ‘square’, ‘cross’, ‘diamond’, ‘triangle-up’, ‘triangle-down’, or else a custom SVG path string.
symbolSize float The size of the legend symbol, in pixels.
symbolStrokeWidth float The width of the symbol’s stroke.
titleColor string Optional mark property definitions for custom legend styling.
titleFont string The font of the legend title.
titleFontSize float The font size of the legend title.
titleFontWeight string The font weight of the legend title.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.MarkConfig(**kwargs)

Wrapper for Vega-Lite MarkConfig definition.

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

Trait Type Description
align string The horizontal alignment of the text. One of [‘left’, ‘right’, ‘center’].
angle float The rotation angle of the text, in degrees.
applyColorToBackground boolean Apply color field to background color instead of the text.
barSize float The size of the bars.
barThinSize float The size of the bars on continuous scales.
baseline string The vertical alignment of the text. One of [‘top’, ‘middle’, ‘bottom’].
color string Default color.
dx float The horizontal offset, in pixels, between the text label and its anchor point.
dy float The vertical offset, in pixels, between the text label and its anchor point.
fill string Default Fill Color.
fillOpacity float
filled boolean Whether the shape’s color should be used as fill color instead of stroke color.
font string The typeface to set the text in .
fontSize float The font size, in pixels.
fontStyle string The font style . One of [‘normal’, ‘italic’].
fontWeight string The font weight . One of [‘normal’, ‘bold’].
format string The formatting pattern for text value.
interpolate string The line interpolation method to use. One of [‘linear’, ‘linear-closed’, ‘step’, ‘step-before’, ‘step-after’, ‘basis’, ‘basis-open’, ‘basis-closed’, ‘cardinal’, ‘cardinal-open’, ‘cardinal-closed’, ‘bundle’, ‘monotone’].
lineSize float Size of line mark.
opacity float
orient string The orientation of a non-stacked bar, tick, area, and line charts. One of [‘horizontal’, ‘vertical’].
radius float Polar coordinate radial offset, in pixels, of the text label from the origin determined by the x and y properties.
ruleSize float Size of rule mark.
shape string or string One of [‘circle’, ‘square’, ‘cross’, ‘diamond’, ‘triangle-up’, ‘triangle-down’].
shortTimeLabels boolean Whether month names and weekday names should be abbreviated.
size float The pixel area each the point.
stacked string One of [‘zero’, ‘center’, ‘normalize’, ‘none’].
stroke string Default Stroke Color.
strokeDash list of float An array of alternating stroke, space lengths for creating dashed or dotted lines.
strokeDashOffset float The offset (in pixels) into which to begin drawing with the stroke dash array.
strokeOpacity float
strokeWidth float
tension float Depending on the interpolation type, sets the tension parameter.
text string Placeholder Text.
theta float Polar coordinate angle, in radians, of the text label from the origin determined by the x and y properties.
tickSize float The width of the ticks.
tickThickness float Thickness of the tick mark.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.OneOfFilter(**kwargs)

Wrapper for Vega-Lite OneOfFilter definition.

Trait Type Description
field string Field to be filtered.
oneOf list of string or float or boolean or DateTime A set of values that the field‘s value should be a member of, for a data item included in the filtered data.
timeUnit string time unit for the field to be filtered. One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.RangeFilter(**kwargs)

Wrapper for Vega-Lite RangeFilter definition.

Trait Type Description
field string Field to be filtered.
range list of float or DateTime Array of inclusive minimum and maximum values for a field value of a data item to be included in the filtered data.
timeUnit string time unit for the field to be filtered. One of [‘year’, ‘month’, ‘day’, ‘date’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘yearmonth’, ‘yearmonthdate’, ‘yearmonthdatehours’, ‘yearmonthdatehoursminutes’, ‘yearmonthdatehoursminutesseconds’, ‘monthdate’, ‘hoursminutes’, ‘hoursminutesseconds’, ‘minutesseconds’, ‘secondsmilliseconds’, ‘quarter’, ‘yearquarter’, ‘quartermonth’, ‘yearquartermonth’].
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.Scale(**kwargs)

Wrapper for Vega-Lite Scale definition.

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

Trait Type Description
bandSize float or string One of [‘fit’].
clamp boolean If true, values that exceed the data domain are clamped to either the minimum or maximum range value.
domain list of float or list of string or list of DateTime
exponent float Sets the exponent of the scale transformation.
nice boolean or string One of [‘second’, ‘minute’, ‘hour’, ‘day’, ‘week’, ‘month’, ‘year’].
padding float Applies spacing among ordinal elements in the scale range.
range string or list of float or list of string
round boolean If true, rounds numeric output values to integers.
type string One of [‘linear’, ‘log’, ‘pow’, ‘sqrt’, ‘quantile’, ‘quantize’, ‘ordinal’, ‘time’, ‘utc’].
useRawDomain boolean Uses the source data range as scale domain instead of aggregated data for aggregate axis.
zero boolean If true, ensures that a zero baseline value is included in the scale domain.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.ScaleConfig(**kwargs)

Wrapper for Vega-Lite ScaleConfig definition.

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

Trait Type Description
bandSize float or string One of [‘fit’].
barSizeRange list of float Default range for bar size scale.
fontSizeRange list of float Default range for font size scale.
nominalColorRange string or list of string
opacity list of float Default range for opacity.
padding float Default padding for x and y ordinal scales.
pointSizeRange list of float Default range for bar size scale.
round boolean If true, rounds numeric output values to integers.
ruleSizeRange list of float Default range for rule stroke widths.
sequentialColorRange string or list of string
shapeRange string or list of string
textBandWidth float Default band width for x ordinal scale when is mark is text.
tickSizeRange list of float Default range for tick spans.
useRawDomain boolean Uses the source data range as scale domain instead of aggregated data for aggregate axis.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

class altair.SortField(**kwargs)

Wrapper for Vega-Lite SortField definition.

Trait Type Description
field string The field name to aggregate over.
op string The sort aggregation operator. 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’].
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

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 string or an Expression or EqualFilter or RangeFilter or OneOfFilter or list of string or an Expression or EqualFilter or RangeFilter or OneOfFilter
filterInvalid boolean Whether to filter invalid values (null and NaN) from the data.
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(spec)

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.

to_dict(data=True)

Emit the JSON representation for this object as as dict.

Parameters:

data : bool

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

Returns:

spec : dict

The JSON specification of the chart object.

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.

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.