为每个matplotlib保存图形

2024-04-19 10:04:38 发布

您现在位置:Python中文网/ 问答频道 /正文

如何为for循环中生成的每个图保存一个图

这是我的密码:

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

Tags: columnsintest密码fordateframesplot
1条回答
网友
1楼 · 发布于 2024-04-19 10:04:38

只需在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]))

相关问题 更多 >