✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Close figures created using plotly

I have a quick question. I have recently started to use plotly offline.
I am running machine learning experiments which saves huge amount of images, in the order of 100s.
I want to close the figures created using plotly.

Previously, I have used matplotlib library, where I used matplotlib.pyplot.close() to close the figures. I would like to know the equivalent of this in plotly.
Can you please help me in this regard?

Hi @cishwarya,

This might not be possible but I would like to understand your use case a little better. How are you displaying the plotly figures (e.g. with iplot in the notebook, with plot in the browser, etc.)? In what format do you want to save them to disk (standalone HTML files, static images, etc.)?


I have the same problem.

I have code similar to this.

import numpy as np
import plotly.express as px
for i in range(1000):
   x = np.random.rand(6,6)
   fig = px.imshow(x)

I seem to have trouble getting it to save the images properly.