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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -