【问题标题】:Python matplotlib insert index in plotPython matplotlib 在图中插入索引
【发布时间】:2013-12-09 14:58:24
【问题描述】:

所以我试图保存在 for 循环的每次迭代后生成的多个图,并且我想在这些图上插入一个名称标签,就像一个标题一样,并完成了迭代次数。代码看起来像这样。我试过suptitle,但它不起作用。

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)

【问题讨论】:

    标签: python-2.7 matplotlib page-numbering


    【解决方案1】:

    plt.title 呢?

    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)
    

    标题调用的字符串格式也有错误。实际上'frame'%i 应该以TypeError: not all arguments converted during string formatting-error 失败。 另请注意,您不需要plt.draw,因为这将由plt.savefig 调用。

    【讨论】:

      猜你喜欢
      • 2014-11-19
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 2019-10-22
      • 2021-10-11
      • 1970-01-01
      • 2019-10-04
      相关资源
      最近更新 更多