Altair is a declarative statistical visualization library for Python built on Vega-Lite, enabling rapid creation of interactive, publication-quality charts with minimal code. Unlike imperative plotting libraries, Altair uses a grammar of graphics approach where you specify what relationships to visualize rather than how to draw them—the library handles rendering details automatically. A key insight: Altair's power lies in its composability—simple chart elements combine through layering, concatenation, and faceting to create sophisticated multi-view dashboards without manual layout calculations.
What This Cheat Sheet Covers
This topic spans 20 focused tables and 162 indexed concepts, 112 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Chart Creation and Mark Types
Every Altair chart begins with alt.Chart(df) and then gets a mark—the geometric shape that actually draws your data. The mark you pick (points, lines, bars, areas, arcs, ticks) decides the type of plot you get, and the same data can switch from a scatter to a line to a heatmap just by swapping one method.
| Method | Example | Description | |
|---|---|---|---|
alt.Chart(df) | • Creates base chart object from pandas DataFrame or URL • all visualizations start here | ||
chart.mark_point() | • Renders scatter plot with circular points • supports filled, size, and shape properties | ||
chart.mark_line() | • Draws connected line chart • use point=True to show both line and points | ||
chart.mark_bar() | • Creates bar chart • automatically stacks when color encoding present | ||
chart.mark_area() | • Fills area between line and baseline • ideal for stacked area charts | ||
chart.mark_circle() | Similar to mark_point but always renders circles regardless of shape encoding | ||
chart.mark_rect() | • Draws rectangles • commonly used for heatmaps with x/y encoding | ||
chart.mark_text() | • Displays text labels • requires text encoding channel for values | ||
chart.mark_tick() | • Renders short tick marks • useful for rug plots along axes | ||
chart.mark_rule() | • Draws straight lines • often used for reference lines or thresholds | ||
chart.mark_arc() | Creates circular arcs for pie and donut charts with theta encoding | ||
chart.mark_trail() | • Line with variable width along path • size encoding controls thickness | ||
chart.mark_geoshape() | Renders geographic shapes from GeoJSON/TopoJSON data | ||
chart.mark_boxplot() | Composite mark showing quartiles, median, and outliers | ||
chart.mark_errorbar() | Displays error ranges with center point and whiskers | ||
chart.mark_image() | • Embeds external images • requires url encoding for image paths |