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().

Info

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

End-to-end example¶

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

comet_ml.login()
experiment = comet_ml.start(
    project_name="comet-example-matplotlib-doc"
)

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')
plt.grid(True)

experiment.log_figure(figure=plt)
experiment.end()
Dec. 17, 2024