Skip to content

How to use Neptune with Altair#

Open in Colab

Altair is a declarative statistical visualization library for Python. With Neptune, you can log and display Altair charts as interactive HTML.

Altair chart in Neptune

See in Neptune  Example script 

Before you start#


To follow the guide without any setup, run the Colab example.

  • Sign up at
  • Create a project for storing your metadata.
  • Have Altair and Neptune installed:

    pip install -U altair neptune
    conda install -c conda-forge altair neptune
Upgrading with neptune-client already installed

Important: To smoothly upgrade to the 1.0 version of the Neptune client library, first uninstall the neptune-client library and then install neptune.

pip uninstall neptune-client
pip install neptune

Altair logging example#

  1. Import Neptune and start a run:

    import neptune
    run = neptune.init_run()  # (1)!
    1. If you haven't set up your credentials, you can log anonymously:

  2. Install vega-datasets to access sample data:

    pip install vega_datasets==0.9.0
    conda install -c conda-forge vega_datasets=0.9.0
  3. Create a sample figure using data from

    import altair as alt
    from vega_datasets import data
    source =
    brush = alt.selection(type="interval")
    points = (
            color=alt.condition(brush, "Origin:N", alt.value("lightgray")),
    bars = (
        .encode(y="Origin:N", color="Origin:N", x="count(Origin):Q")
    chart = points & bars
  4. Upload the chart:

  5. To stop the connection to Neptune and sync all data, call the stop() method:

  6. Run your script as you normally would.

    To open the run, click the Neptune link that appears in the console output.

    Example link:


The resulting chart is logged as an HTML object.

You can view it in the All metadata section.