explaingit

vega/altair

10,375PythonAudience · dataComplexity · 2/5Setup · easy

TLDR

Vega-Altair is a Python library for creating charts by describing what you want rather than drawing it step by step, a few lines produce interactive scatter plots, bar charts, and linked views.

Mindmap

mindmap
  root((repo))
    What it does
      Declarative charting
      Python to Vega-Lite
      Interactive views
    Chart types
      Scatter plots
      Bar charts
      Linked dashboards
    Output formats
      JupyterLab
      Standalone HTML
      PNG and SVG
    Audience
      Data analysts
      Researchers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Create an interactive scatter plot from a data file where clicking a point highlights it in a linked bar chart.

USE CASE 2

Export a polished data visualization as standalone HTML to share with stakeholders who have no Python setup.

USE CASE 3

Build a multi-view dashboard in a Jupyter notebook where brushing one chart filters all the others.

Tech stack

PythonVega-LiteJupyterLab

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Vega-Altair is a Python library for creating charts and graphs from data. It takes a declarative approach, meaning you describe what your visualization should look like (which columns map to which axes, how to color points, what chart type to use) rather than writing code that draws each element step by step. This makes it possible to produce complex charts with only a few lines of code. The library is built on top of Vega-Lite, an open specification for defining visualizations as JSON objects. When you write an Altair chart in Python, you are constructing that JSON specification through a Python API. The resulting chart can be displayed in JupyterLab, Jupyter Notebook, Visual Studio Code, or GitHub, and can be exported as PNG, SVG, standalone HTML, or a JSON file. A key feature inherited from Vega-Lite is support for interaction. You can define selections (like clicking or brushing a region of a scatter plot) and link them to other charts so that filtering one view automatically updates another. The README demonstrates this with an example where brushing a scatter plot of car data filters a bar chart showing the count of cars by country of origin. Installation is through pip or conda. The library is available on PyPI as the package named altair. Documentation, gallery examples, and interactive tutorial notebooks are at altair-viz.github.io. The notebooks can also be run directly in the browser through Binder or Google Colab without any local installation. Vega-Altair was originally developed by researchers at the University of Washington Interactive Data Lab and has been published as an academic paper in the Journal of Open Source Software. It is not affiliated with Altair Engineering, a separate company with a similar name.

Copy-paste prompts

Prompt 1
Using Vega-Altair, write Python code to create a scatter plot from a CSV file where brushing a region filters a linked bar chart.
Prompt 2
Show me how to make an Altair chart with a color-coded legend where clicking a legend item highlights that group of points.
Prompt 3
How do I export an Altair chart as a standalone HTML file I can email to someone without any Python installed?
Open on GitHub → Explain another repo

← vega on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.