python - Exit graph window using matplotlib.pyplot in terminal? -
i wrote command-line program in python
using matplotlib.pyplot
, argparse
. input data , scatterplot i'm looking , window pops graph. cool how can exit window terminal ?
i ended adding argparse argument --exit
sys.exit()
it's not working...when ctrl+z
stops script graph window stays open.
how can exit matplotlib.pyplot graph window terminal?
#!/usr/bin/env python2.7 import matplotlib.pyplot plt import argparse, sys def main(): #(i). add arguments parser = argparse.argumentparser(description=__doc__) parser.add_argument('--exit', action = 'store_true', = 'exit graph') options = parser.parse_args() x_coordinates = [1,2,3,4,5] y_coordinates = [3,3,3,3,3] size_map = [20,20,20,20,20] plt.scatter(x_coordinates,y_coordinates, s = size_map) plt.show() if options.exit: sys.exit() #initiate if __name__ == '__main__': main()
Comments
Post a Comment