Altair

🧠 What is Altair

Declarative statistical visualization library for Python, built on Vega-Lite. You describe what the data means (this column is quantitative, that one is a category) and Altair figures out how to draw it. Output is interactive by default (zoom, tooltips, selections) and renders as JSON spec → JavaScript/SVG, not a static image like Matplotlib.

Matplotlib/SeabornAltair
ParadigmImperative (you draw each element)Declarative (you describe encodings, it draws)
OutputStatic image (PNG/PDF) by defaultInteractive HTML/JSON (Vega-Lite spec)
SyntaxFunction callsMethod chaining on a Chart object
Data inputArrays or DataFrame columnsDataFrame only

Every Altair chart is built the same way: Chart(data).mark_X().encode(...). Learn that shape once, everything else is variations on it.

📚 Map of Content

⚡ Minimal example

import altair as alt
import pandas as pd
 
df = pd.DataFrame({"x": [1,2,3], "y": [4,1,5]})
 
chart = alt.Chart(df).mark_line(point=True).encode(
    x="x",
    y="y"
)
chart.show()   # or chart in a Jupyter cell, or chart.save("out.html")
pip install altair vega_datasets