I am trying to save a graph over a series of images (300 images). I thought the best way to do this would be using matplotlib.pyplot.savefig(); however, this takes a long time. How can I accomplish this faster? Here is my code.
for b in range(300):
im = plt.imshow(green[b])
plt.plot([b,3],[5,b]) # This isn't the actual plot. Just an example
plt.savefig('frame_' + str(b) + '.tif')
Then with those results, I am just adding them to a list to concatenate them into a single tiff file. Therefore, my final results are a video of these images with the same plot overlayed throughout. This second part of code is not an issue. I am just including this for reference of what I am trying to accomplish overall.
my_list = []
for a in range(300):
my_list.append('frame_'+str(a)+'.tif')
tifftools.tiff_concat(my_list, 'Tracks.tiff')