Skip to content

Integrate with Matplotlib

Comet integrates with Matplotlib to let you upload figures and plots.

After creating the figure in Matplotlib, just call Experiment.log_figure().


Plots and figures uploaded using that method will be available under the Graphics tab in the Experiment view.

End-to-end example

import matplotlib as mpl

# mpl.use('Agg') if you are on a headless machine

import matplotlib.pyplot as plt
import numpy as np
from comet_ml import Experiment

experiment = Experiment(project_name="matplotlib")

t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)

plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')

Feb. 24, 2024