Save plot to image file instead of displaying it using Matplotlib

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

    If you don't like the concept of the "current" figure, do:

    import matplotlib.image as mpimg
    
    img = mpimg.imread("src.png")
    mpimg.imsave("out.png", img)
    

提交回复
热议问题