сохранение графика для каждого matplotlib - PullRequest
0 голосов
/ 21 мая 2019

Как сохранить график для каждого графика, созданного в цикле for?

Вот мой код:

for frame in all_frames:
  test[frame.columns[0]].plot(kind = 'line', x = 'date')
  plt.ylabel('Percent Change from Month and Year Prior')

1 Ответ

0 голосов
/ 21 мая 2019

Просто добавьте matplotlib.pyplot.savefig внутри цикла for:

for frame in all_frames:
    test[frame.columns[0]].plot(kind = 'line', x = 'date')
    plt.ylabel('Percent Change from Month and Year Prior')
    plt.savefig('{}'.format(frame.columns[0]))
...