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.findall(r"(\d+)",text)
x = [int(i) for i in liveRatio]
pylab.plot(x)
F = pylab.gcf()
F.savefig('benchmark',dpi=200)
The code plots all the data on the same plot. But, I want individual separate plots for each benchmark.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.