Neptune-Matplotlib IntegrationΒΆ

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

matplotlib integration

Follow these steps:

  1. Create an experiment:

    import neptune
  2. Create a matplotlib figure:

    For example:

    # matplotlib figure example 2
    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])
  3. Log figure into Neptune:

Log as static image

experiment.log_image('diagrams', figure)

Log as interactive plotly chart

from neptunecontrib.api import log_chart

log_chart(name='matplotlib_figure', chart=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.

  1. Explore the results in the Neptune dashboard:

Static image is logged into the logs section:


Interactive figure is logged as artifact into the charts folder. Check out this experiment in the app.



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