Save plot to image file instead of displaying it using Matplotlib

前端 未结 20 1368
一生所求
一生所求 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:35

    You can do it like this:

    def plotAFig():
      plt.figure()
      plt.plot(x,y,'b-')
      plt.savefig("figurename.png")
      plt.close()
    

提交回复
热议问题