Matplotlib: Plot Multiple Individual Plots In A Loop
I want to plot multiple benchmarks, each on a separate plot. Here's my code: for benchmark in benchmarks: readFile = open(benchmark+'.txt') text = readFile.read() x = re.f
Solution 1:
You need to clear the figure before each plot call:
for benchmark in benchmarks:
readFile = open(benchmark+'.txt')
text = readFile.read()
x = re.findall(r"(\d+)",text)
x = [int(i) for i in liveRatio]
#clear the figure
pylab.clf()
pylab.plot(x)
F = pylab.gcf()
F.savefig('benchmark',dpi=200)
On a second note each time you iterate the figure will be overwritten so I suggest something like this:
F.savefig(benchmark+'.png',dpi=200)
Post a Comment for "Matplotlib: Plot Multiple Individual Plots In A Loop"