Neptune-Matplotlib Integration

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

matplotlib neptune.ai integration

Follow these steps:

  1. Create an experiment:

    import neptune
    
    neptune.init(api_token='ANONYMOUS',project_qualified_name='shared/showroom')
    neptune.create_experiment()
    
  2. Create a matplotlib figure:

    For example:

    # matplotlib figure example 2
    from matplotlib import pyplot
    import numpy
    
    numpy.random.seed(19680801)
    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])
    axs[1, 1].hist2d(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)
  1. Explore the results in the Neptune dashboard:

Static image is logged into the logs section:

image

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

image