【发布时间】:2012-11-20 21:10:11
【问题描述】:
我需要在 Python 中使用“savefig”来保存 while 循环的每次迭代的绘图,并且我希望我给该图的名称包含文字部分和数字部分。这个来自一个数组,或者是与迭代索引相关的数字。我举个简单的例子:
# 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]
非常感谢。
【问题讨论】:
标签: python image indexing save figure