Close figures created using plotly

@cishwarya
Perhaps resetting the figure and re-using it does the trick for you ? It did for me.

@garland3
fig.show() clears the image.

switch the order

   fig.write_image(f"mycool_array_{i}.png")
   fig.show()