Working with Matplotlib#
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
See in Neptune  Code examples  
Before you start#
- Set up Neptune. Instructions:
-
Install Matplotlib:
(Optional) To log static Matplotlib figures as interactive Plotly charts, install the plotly library:
Plotly incompatibility
Plotly is not compatible with the latest Matplotlib (3.5.0+) due to the fact that mpl_to_plotly()
uses deprecated Matplotlib functionalities.
To use Plotly together with Matplotlib, you may need to downgrade your Matplotlib version to <3.5
. For more information, see Plotly issue 1568 and issue 3624 on GitHub.
Matplotlib logging example#
-
Import Neptune and start a run:
- If you haven't set up your credentials, you can log anonymously:
neptune.init_run(api_token=neptune.ANONYMOUS_API_TOKEN, project="common/matplotlib-support")
- If you haven't set up your credentials, you can log anonymously:
-
Create a sample figure:
-
Log the figure to Neptune
-
As a static image:
-
(With Plotly installed) As an interactive Plotly chart:
Info
Not all Matplotlib charts can be converted to interactive Plotly charts. If the conversion is not possible, Neptune falls back to logging the chart as an image.
-
-
To stop the connection to Neptune and sync all data, call the
stop()
method:Using
stop()
is especially important in Jupyter Notebook or other interactive sessions, as the connection otherwise remains open until the session ends completely. -
To open the run, click the Neptune link in the console output.
Example link: https://app.neptune.ai/common/matplotlib-support/e/MAT-1
-
Explore the figures in the All metadata section: