Overview#

Vega-Altair is a declarative statistical visualization library for Python, based onVega andVega-Lite.

It offers a powerful and concise grammar that enables you to quickly builda wide range of statistical visualizations. Here is an example of using theAPI to visualize a dataset withan interactive scatter plot:

# import altair with an abbreviated aliasimportaltairasalt# load a sample dataset as a pandas DataFramefromvega_datasetsimportdatacars=data.cars()# make the chartalt.Chart(cars).mark_point().encode(x='Horsepower',y='Miles_per_Gallon',color='Origin',).interactive()

The key idea is that you are declaring links betweendata columns andvisual encodingchannels, such as the x-axis, y-axis and color. The rest of the plot details arehandled automatically. Building on this declarative system, a surprising rangeof plots, from simple to sophisticated, can be created using aconcise grammar.

The project is named after thebrightest starin the constellation Aquila. From Earth’s sky Altair appears close to Vega, the star from which our parent project drew its name.

This documentation serves as the main reference for learning about Altair. Additional learning material and tutorials can be found in theLearning Material section. It can also be helpful to browse theVega-Lite documentation.