I am trying to plot intermediary plots (or subplots) on which we add new data in a loop (just dots, no legend or anything). Is there a way to reuse the previously saved plots and draw the new data over it so that the computation time of savefig doesn't grow at every iteration?
A solution that could work would be to save the inside of the window, and then load it and plot over it. However I have no idea if that's possible or how to implement it.
One simple example of a problematic code where the savefig call duration increases:
import time
import matplotlib.pyplot as plt
import numpy
fig = plt.figure()
for i in range(10):
x = numpy.random.rand(100000)
y = numpy.random.rand(100000)
plt.plot(x, y, '.')
t = time.time()
fig.savefig('ZZZZ%d.jpg' % i)
elapsed = time.time() - t
print("%.2fs" % elapsed)