How can I show figures separately in matplotlib?

后端 未结 7 1213
面向向阳花
面向向阳花 2020-11-29 18:58

Say that I have two figures in matplotlib, with one plot per figure:

import matplotlib.pyplot as plt

f1 = plt.figure()
plt.plot(range(0,10))
f2 = plt.figure         


        
相关标签:
7条回答
  • 2020-11-29 19:47

    As of November 2020, in order to show one figure at a time, the following works:

    import matplotlib.pyplot as plt
    
    f1, ax1 = plt.subplots()
    ax1.plot(range(0,10))
    f1.show()
    input("Close the figure and press a key to continue")
    f2, ax2 = plt.subplots()
    ax2.plot(range(10,20))
    f2.show()
    input("Close the figure and press a key to continue")
    

    The call to input() prevents the figure from opening and closing immediately.

    0 讨论(0)
提交回复
热议问题