This code has a 4-dimensional array of 13x13 images. I would like to save each 13x13 image using matplotlib.pyplot. Here, for debugging purposes, I limit the outer loop to 1.
no_images = 4000
for m in [1]:
for i in range(no_images):
print i,
fm = fts[i][m]
if fm.min() != fm.max():
fm -= fm.min()
fm /= fm.max()
else:
print 'unscaled'
plt.imshow(fmap)
plt.savefig('m'+str(m)+'_i'+str(i)+'.png')
Saving 4000 images took more than 20 hours. Why is it so slow? If I limit the inner loop to the first 100 images, it will take about 1 minute. Thus, all this should be completed in 40 minutes, not in 20 hours! And I notice that it works more slowly.
source
share