Save plot to image file instead of displaying it using Matplotlib

前端 未结 20 1399
一生所求
一生所求 2020-11-22 06:07

I am writing a quick-and-dirty script to generate plots on the fly. I am using the code below (from Matplotlib documentation) as a starting point:

from pylab         


        
20条回答
  •  醉话见心
    2020-11-22 06:43

    When using matplotlib.pyplot, you must first save your plot and then close it using these 2 lines:

    fig.savefig('plot.png') # save the plot, place the path you want to save the figure in quotation
    plt.close(fig) # close the figure window
    

提交回复
热议问题