Creating plots with Altair and the Vega-Lite specification

Vega is a declarative format for designing static and interactive visualizations. It provides a JSON-based visualization grammar that focuses on the what instead of the how. Vega-Lite is a higher-level specification that is easier to use than Vega, and that compiles directly to Vega.

Altair is a Python library that provides a simple API to define and display Vega-Lite visualizations. It works in the Jupyter Notebook, JupyterLab, and nteract.

Note

Altair is under active development and some details of the API might change in future versions.

Getting started...

Install Altair with conda install -c conda-forge altair.

How to do it...

  1. Let's import Altair:
    >>> import altair as alt
  2. Altair provides ...

Get IPython Interactive Computing and Visualization Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.