Video Walkthrough

What will you get with this integration?

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. This integration lets you log charts generated in matplotlib to Neptune for easy reference and collaboration.


This guide will show you how to:

  • Initialize Neptune and create a run,

  • Log matplotlib charts to Neptune.

Step 0: Before you start

Install neptune-client and matplotlib:

pip install --upgrade --quiet neptune-client matplotlib

This integration is tested with neptune-client==0.9.5 and matplotlib==3.2.2

Step 1: Import and initialize Neptune

import as neptune
run = neptune.init(api_token='<your_api_token>',

You can use the api_token='ANONYMOUS' and project='common/matplotlib-support' to explore without having to create a Neptune account

Executing this cell will give you a link looking like: with common/matplotlib-support replaced by your project, and MAT-1 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 Matplotlib figures to Neptune

Create a sample figure

import matplotlib.pyplot as plt
import numpy as np
data = np.random.randn(2, 100)
figure, ax = plt.subplots(2, 2, figsize=(5, 5))
ax[0, 0].hist(data[0])
ax[1, 0].scatter(data[0], data[1])
ax[0, 1].plot(data[0], data[1])

Log as static image

run['static-img'] = neptune.types.File.as_image(figure)

Log as interactive chart

run['interactive-img'] = neptune.types.File.as_html(figure)

This option is tested with matplotlib==3.2.2 and plotly==4.14.3. Make sure that you have correct versions installed.

Not all matplotlib charts can be converted to interactive plotly charts. If conversion is not possible, neptune-client will return a warning and fall back on logging the chart as an image.

Step 3: Explore the charts in Neptune

The images can be found in the All metadata section:

Step 4: 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.



You’ve learned how to:

  • Initialize Neptune and create a run,

  • Log matplotlib charts to Neptune.

What's next

Now that you know how to log charts to Neptune, you can learn: