• <legend id='TetcH'><style id='TetcH'><dir id='TetcH'><q id='TetcH'></q></dir></style></legend>

    <small id='TetcH'></small><noframes id='TetcH'>

  • <tfoot id='TetcH'></tfoot>
    • <bdo id='TetcH'></bdo><ul id='TetcH'></ul>

        <i id='TetcH'><tr id='TetcH'><dt id='TetcH'><q id='TetcH'><span id='TetcH'><b id='TetcH'><form id='TetcH'><ins id='TetcH'></ins><ul id='TetcH'></ul><sub id='TetcH'></sub></form><legend id='TetcH'></legend><bdo id='TetcH'><pre id='TetcH'><center id='TetcH'></center></pre></bdo></b><th id='TetcH'></th></span></q></dt></tr></i><div id='TetcH'><tfoot id='TetcH'></tfoot><dl id='TetcH'><fieldset id='TetcH'></fieldset></dl></div>

        在名称中使用字符串和迭代索引的 Python 中的 savefig

        Use savefig in Python with string and iterative index in the name(在名称中使用字符串和迭代索引的 Python 中的 savefig)
          <bdo id='SfPe0'></bdo><ul id='SfPe0'></ul>

            <tfoot id='SfPe0'></tfoot>
            <legend id='SfPe0'><style id='SfPe0'><dir id='SfPe0'><q id='SfPe0'></q></dir></style></legend>

              <i id='SfPe0'><tr id='SfPe0'><dt id='SfPe0'><q id='SfPe0'><span id='SfPe0'><b id='SfPe0'><form id='SfPe0'><ins id='SfPe0'></ins><ul id='SfPe0'></ul><sub id='SfPe0'></sub></form><legend id='SfPe0'></legend><bdo id='SfPe0'><pre id='SfPe0'><center id='SfPe0'></center></pre></bdo></b><th id='SfPe0'></th></span></q></dt></tr></i><div id='SfPe0'><tfoot id='SfPe0'></tfoot><dl id='SfPe0'><fieldset id='SfPe0'></fieldset></dl></div>
                <tbody id='SfPe0'></tbody>

                • <small id='SfPe0'></small><noframes id='SfPe0'>

                  本文介绍了在名称中使用字符串和迭代索引的 Python 中的 savefig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要使用 Python 中的savefig"来保存 while 循环的每次迭代的图,并且我希望我给该图的名称包含文字部分和数字部分.这个来自数组或者是与迭代索引相关的数字.我举个简单的例子:

                  I need to use the "savefig" in Python to save the plot of each iteration of a while loop, and I want that the name i give to the figure contains a literal part and a numerical part. This one comes out from an array or is the number associated to the index of iteration. I make a simple example:

                  # index.py
                  
                  from numpy import *
                  from pylab import *
                  from matplotlib import *
                  from matplotlib.pyplot import *
                  import os
                  
                  x=arange(0.12,60,0.12).reshape(100,5)
                  y=sin(x)
                  
                  i=0
                  
                  while i<99
                    figure()
                    a=x[:,i]
                    b=y[:,i]
                    c=a[0]
                    plot(x,y,label='%s%d'%('x=',c))
                  
                    savefig(#???#)      #I want the name is: x='a[0]'.png
                                        #where 'a[0]' is the value of a[0]
                  

                  非常感谢.

                  推荐答案

                  嗯,应该是这样的:

                  savefig(str(a[0]))
                  

                  这是一个玩具示例.对我有用.

                  This is a toy example. Works for me.

                  import pylab as pl
                  import numpy as np
                  
                  # some data
                  x = np.arange(10)
                  
                  pl.figure()
                  pl.plot(x)
                  pl.savefig('x=' + str(10) + '.png')
                  

                  这篇关于在名称中使用字符串和迭代索引的 Python 中的 savefig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                  <i id='fItCu'><tr id='fItCu'><dt id='fItCu'><q id='fItCu'><span id='fItCu'><b id='fItCu'><form id='fItCu'><ins id='fItCu'></ins><ul id='fItCu'></ul><sub id='fItCu'></sub></form><legend id='fItCu'></legend><bdo id='fItCu'><pre id='fItCu'><center id='fItCu'></center></pre></bdo></b><th id='fItCu'></th></span></q></dt></tr></i><div id='fItCu'><tfoot id='fItCu'></tfoot><dl id='fItCu'><fieldset id='fItCu'></fieldset></dl></div>
                    <bdo id='fItCu'></bdo><ul id='fItCu'></ul>
                        <tbody id='fItCu'></tbody>
                    1. <tfoot id='fItCu'></tfoot>

                        • <small id='fItCu'></small><noframes id='fItCu'>

                            <legend id='fItCu'><style id='fItCu'><dir id='fItCu'><q id='fItCu'></q></dir></style></legend>