1

I'm using matplotlib. Code:

for new_counter in range(counter+1):
    print new_counter
    Qbers = final_data[(final_data["Dataset"]==counter) & (final_data["Qber"] > 0) ]
    x1 = Qbers.index.tolist()
    y1 = Qbers["Qber"].tolist()
    Raws = final_data[(final_data["Dataset"]==counter) & (final_data["Raw key"] > 0) ]
    x2 = Raws.index.tolist()
    y2 = Raws["Raw key"].tolist()
    # Two subplots, the axes array is 1-d http://matplotlib.org/examples/pylab_examples/subplots_demo.html
    f, axarr = plt.subplots(2, sharex=True)
    axarr[0].grid()
    axarr[0].plot(x1, y1)
    axarr[0].set_title('Sharing X axis')
    axarr[1].grid()
    axarr[1].plot(x2, y2)
    plt.savefig(str(counter)+'foo.eps')
    plt.clf()

I'm receiving only file with last plot, and with my data I should receive 6 of them. How to fix that? Additional question: How to prevent creation of interactive window with plot?

Damian Melniczuk
  • 393
  • 6
  • 18
  • Here's a relevant SO question: http://stackoverflow.com/questions/1358977/how-to-make-several-plots-on-a-single-page-using-matplotlib – GomoX Jan 10 '14 at 16:50

1 Answers1

1

It looks like you are not generating unique file names. You probably want:

plt.savefig(str(new_counter)+'foo.eps')
Molly
  • 13,240
  • 4
  • 44
  • 45