Python 2.7 Python matplotlib在绘图中插入索引
因此,我试图保存在for循环每次迭代后生成的多个图,并且我想在这些图上插入一个名称标记,就像一个包含迭代次数的标题一样。代码看起来像这样。我试过了,但没用Python 2.7 Python matplotlib在绘图中插入索引,python-2.7,matplotlib,page-numbering,Python 2.7,Matplotlib,Page Numbering,因此,我试图保存在for循环每次迭代后生成的多个图,并且我想在这些图上插入一个名称标记,就像一个包含迭代次数的标题一样。代码看起来像这样。我试过了,但没用 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, e
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)
那怎么办
标题调用的字符串格式也有错误。实际上,”帧“%i
应该失败,并出现类型错误:在字符串格式化过程中,并非所有参数都转换成了-错误。
另外请注意,您不需要plt.draw
,因为它将由plt.savefig
调用
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.title('frame %d'%i, fontsize=12)
plt.savefig("flie%d.png"%i)