So I am trying to save multiple plots which are generated after every iteration of a for loop and I want to insert a name tag on those plots like a header with the number of iterations done. code looks like this. I tried suptitle but it does not work.
for i in range(steps):
nor_m = matplotlib.colors.Normalize(vmin = 0, vmax = 1)
plt.hexbin(xxx,yyy,C, gridsize=13, cmap=matplotlib.cm.rainbow, norm=nor_m, edgecolors= 'k', extent=[-1,12,-1,12])
plt.draw()
plt.suptitle('frame'%i, fontsize=12)
savefig("flie%d.png"%i)
What about plt.title?
You also had an error in the string formatting of the title call. Actually
'frame'%i
should have failed with anTypeError: not all arguments converted during string formatting
-error. Note also, that you don't need theplt.draw
, since this will be called byplt.savefig
.