Developed by Jake Vanderplas and Brian Granger, Altair is a python’s library for statistical visualization. Although python provides a number of libraries for the task of data visualization, however what makes altair stand out is its declarative nature. This means a researcher or programmer can focus more on understanding data and its meaning rather than on the code needed to do so.
The Altair is a consistent API and is built on top of the vega and Vega-Lite. Both of these visualization grammars describe the visual appearance and interactive behavior of a visualization in a JSON format. Thus resulting in elegant and effective visualizations with a minimal amount of code.
Installation:
To install Altier write pip command in console. Make sure you have python upgraded version because the minimal Python requirement for altair is python 3.7. we also need to import vega datasets to be used further in exapmle. Along with that we will import pandas package since data in Altair is built around the Pandas Dataframe.
#install altair and data set
$ pip install altair vega_datasets
#install packages
import altair as alt
import pandas as pd
Example:
# load a sample dataset as a pandas DataFrame
from vega_datasets import data
cars = data.cars()
# make the chart
alt.Chart(cars).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
).interactive()
