0

I want to save every plot in a PDF document, but only the last plot is saved.

Here is my code:

for pair in indices:
    y1 = c[pair[0]]
    y2 = c[pair[1]]

    fig = plt.figure(figsize=(10,4))
    ax1 = fig.add_subplot(111)
    ax1.plot(x, y1, "-o", color='b')
    plt.ylabel(pair[0])

    ax2 = ax1.twinx()
    ax2.plot(x, y2,"-o" ,color='r')
    for tl in ax2.get_yticklabels():
        tl.set_color('r')

    plt.title('Reihe')
    plt.ylabel(pair[1])

    plt.savefig("title2.pdf", dpi=300)
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
mgm841
  • 27
  • 6

0 Answers0