How to use 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#
- Sign up at neptune.ai/register.
- Create a project for storing your metadata.
-
Have Altair and Neptune installed:
Tip
To follow the guide without any setup, run the example notebook in Colab
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_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_params(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.
[neptune] [info ] Neptune initialized. Open in the app:
https://app.neptune.ai/workspace/project/e/RUN-1
Result
The resulting chart is logged as an HTML object.
You can view it in the All metadata section.