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#

  • 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


To follow the guide without any setup, run the example notebook in Colab

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
    conda install -c conda-forge vega_datasets
  3. Create a sample figure using data from

    import altair as alt
    from vega_datasets import data
    source =
    brush = alt.selection_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.

[neptune] [info ] Neptune initialized. Open in the app:


The resulting chart is logged as an HTML object.

You can view it in the All metadata section.