• <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

        时间:2023-11-08
          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Django 删除未使用的媒体文件 下一篇:如何将网页保存为文本文件 [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>
                  1. <tfoot id='fItCu'></tfoot>

                    1. <small id='fItCu'></small><noframes id='fItCu'>

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