Command line arguments support — Python documentation

Note

Click here to download the full example code

# Command line arguments support

Use command line arguments to control example script.

    import sys

    import numpy as np
    import matplotlib.pyplot as plt

    if len(sys.argv) > 1 and sys.argv[1] == 'plot':
        fig_0, ax_0 = plt.subplots(figsize=(5, 1))

        x = np.arange(0, 10., 1)
        ax_0.plot(x, x**2)
        plt.show()

Total running time of the script: ( 0 minutes 0.042 seconds)

Gallery generated by Sphinx-Gallery