view and then close the figure automatically in matplotlib?

前端 未结 1 378
礼貌的吻别
礼貌的吻别 2020-12-10 12:07

I have to check whether my parameters setting is right, so I need to draw many plots, and for drawing these plots, I choose to use matplotlib. After each checking, I need to

相关标签:
1条回答
  • 2020-12-10 12:14

    Documentation on pyplot.show() reads:

    matplotlib.pyplot.show(*args, **kw)

    Display a figure. When running in ipython with its pylab mode, display all figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until the figures have been closed; in interactive mode it has no effect unless figures were created prior to a change from non-interactive to interactive mode (not recommended). In that case it displays the figures but does not block.

    A single experimental keyword argument, block, may be set to True or False to override the blocking behavior described above.

    So the solution is this:

    plt.show(block=False)
    plt.pause(3)
    plt.close()
    
    0 讨论(0)
提交回复
热议问题