Using Neptune with Altair#
Altair is a declarative statistical visualization library for Python. With Neptune, you can log and display Altair charts as interactive HTML.
See in Neptune  Example script 
Before you start#
Tip
To follow the guide without any setup, run the Colab example.
- Sign up at neptune.ai/register.
- Create a project for storing your metadata.
-
Have Altair and Neptune installed:
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
.
Altair logging example#
-
Import Neptune and start a run:
-
If you haven't set up your credentials, you can log anonymously:
-
-
Install vega-datasets to access sample data:
-
Create a sample figure using data from
vega_datasets.data.cars()
:import altair as alt from vega_datasets import data source = data.cars() brush = alt.selection(type="interval") points = ( alt.Chart(source) .mark_point() .encode( x="Horsepower:Q", y="Miles_per_Gallon:Q", color=alt.condition(brush, "Origin:N", alt.value("lightgray")), ) .add_selection(brush) ) bars = ( alt.Chart(source) .mark_bar() .encode(y="Origin:N", color="Origin:N", x="count(Origin):Q") .transform_filter(brush) ) chart = points & bars
-
Upload the chart:
-
To stop the connection to Neptune and sync all data, call the
stop()
method: -
Run your script as you normally would.
To open the run, click the Neptune link that appears in the console output.
Example link: https://app.neptune.ai/common/altair-support/e/AL-1/metadata
Result
The resulting chart is logged as an HTML object.
You can view it in the All metadata section.