0

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.

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.