How to show matplotlib plots?

In matplotlib you have two main options:

  1. Create your plots and draw them at the end:

    import matplotlib.pyplot as plt
    
    plt.plot(x, y)
    plt.plot(z, t)
    plt.show()
    
  2. Create your plots and draw them as soon as they are created:

    import matplotlib.pyplot as plt
    from matplotlib import interactive
    interactive(True)
    
    plt.plot(x, y)
    raw_input('press return to continue')
    
    plt.plot(z, t)
    raw_input('press return to end')
    

Leave a Comment