Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Python matplotlib在绘图中插入索引_Python 2.7_Matplotlib_Page Numbering - Fatal编程技术网

Python 2.7 Python matplotlib在绘图中插入索引

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循环每次迭代后生成的多个图,并且我想在这些图上插入一个名称标记,就像一个包含迭代次数的标题一样。代码看起来像这样。我试过了,但没用

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)