Declarative Visualization in Python¶
Altair is a declarative statistical visualization library for Python, based on Vega-Lite.
With Altair, you can spend more time understanding your data and its meaning. Altair’s API is simple, friendly and consistent and built on top of the powerful Vega-Lite visualization grammar. This elegant simplicity produces beautiful and effective visualizations with a minimal amount of code.
Note: Altair and the underlying Vega-Lite library are under active development; new plot types and streamlined plotting interfaces will be added in future releases. Please stay tuned for developments in the coming months! – October 2016
Here is an example of using the Altair API to quickly visualize a dataset:
from altair import Chart, load_dataset # load built-in dataset as a pandas DataFrame cars = load_dataset('cars') Chart(cars).mark_circle().encode( x='Horsepower', y='Miles_per_Gallon', color='Origin', )
The key idea is that you are declaring links between data columns to encoding channels, such as the x-axis, y-axis, color, etc. and the rest of the plot details are handled automatically. Building on this declarative plotting idea, a surprising number of useful plots and visualizations can be created.
- Altair Tutorials
- Altair Frequently Asked Questions
- Altair Documentation
- Example Gallery
- Altair Plot Recipes
- API Reference