This integration lets you log charts generated in matplotlib, like confusion matrix or distribution, in Neptune.

Log Matplotlib charts

Follow these steps:

Create a run

import as neptune
run = neptune.init(project='my_workspace/my_project')

Create a matplotlib figure

# matplotlib figure example
from matplotlib import pyplot
import numpy
data = numpy.random.randn(2, 100)
figure, axs = pyplot.subplots(2, 2, figsize=(5, 5))
axs[0, 0].hist(data[0])
axs[1, 0].scatter(data[0], data[1])
axs[0, 1].plot(data[0], data[1])

Log as static image

run['matplotlib-fig'] = neptune.types.File.as_image(figure)

Log as interactive chart

run['matplotlib-fig'] = neptune.types.File.as_html(figure)

This option is tested with matplotlib==3.2.0 and plotly==4.12.0. Make sure that you have correct versions installed. In the absence of plotly, log_chart silently falls back on logging the chart as a static image.

Explore the results in Neptune

Static image can be found in the all metadata section:

Static image can be found in the all metadata section:

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.