gitmyhub

altair

Python ★ 10k updated 3d ago

Declarative visualization library for Python

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.

PythonVega-LiteJupyterLabsetup: easycomplexity 2/5

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.

Where it fits