Save plot to image file instead of displaying it using Matplotlib

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

    import matplotlib.pyplot as plt
    plt.savefig("image.png")
    

    In Jupyter Notebook you have to remove plt.show() and add plt.savefig(), together with the rest of the plt-code in one cell. The image will still show up in your notebook.

提交回复
热议问题