Plotly
Video Walkthrough

What will you get with this integration?

Plotly is one of the most common python graphing libraries to make interactive graphs. This integration lets you log interactive charts generated in plotly to Neptune.

Introduction

This guide will show you how to:
    Initialize Neptune and create a run,
    Log plotly charts to Neptune.

Step 0: Before you start

Before you start, make sure that:

Install neptune-client and plotly

Depending on your operating system open a terminal or CMD and run this command. All required libraries are available via pip and conda:
pip
conda
1
pip install neptune-client plotly
Copied!
1
conda install -c conda-forge neptune-client plotly
Copied!
For more help see installing neptune-client.
This integration is tested with neptune-client==0.9.19and plotly==5.0.0.

Step 1: Import and initialize neptune

1
import neptune.new as neptune
2
3
run = neptune.init(api_token='<your_api_token>',
4
project='<your_project_name>')
Copied!
You can use the api_token='ANONYMOUS' and project='common/plotly-support' to explore without having to create a Neptune account
Executing this cell will give you a link looking like: https://app.neptune.ai/common/plotly-support/e/PLOT-2 with common/plotly-support replaced by your project, and PLOT-2 replaced by your run.
Click on the link to open the run in Neptune. For now, it is empty but keep the tab with the run open to see what happens next.

Step 2: Log Plotly figures to Neptune

Create a sample figure

1
import plotly.express as px
2
3
df = px.data.iris()
4
plotly_fig = px.scatter_3d(df,
5
x='sepal_length', y='sepal_width', z='petal_width',
6
color='species')
Copied!

Log interactive figure

1
run['interactive_img'].upload(neptune.types.File.as_html(plotly_fig))
Copied!

Step 3: Stop logging

Once you are done logging, you should stop tracking the run using the stop() method. This is needed only while logging from a notebook environment. While logging through a script, Neptune automatically stops tracking once the script has completed execution.
1
run.stop()
Copied!

Step 4: Explore the results in the Neptune

The images can be found in the All Metadata section:

Conclusion

You have learned how to:
    Initialize Neptune and create a run,
    Log plotly charts to Neptune.

What's next

Now that you know how to log charts to Neptune, you can learn:
Last modified 1mo ago