### Exercise 5.16 ### Plot data from a file ### OCL import sys import matplotlib.pyplot as plt # We find file name on the command line fname = sys.argv[1] # We read data into two lists temp = [] dens = [] # File reading infile = open(fname, 'r') for line in infile: words = line.split(); # We assume that a line not starting with a hash # symbol and with at least two words contains data if len(words) >= 2 and words[0] != '#': temp.append(float(words[0])) dens.append(float(words[1])) infile.close() # Plot density vs. temperature plt.plot(temp, dens, 'bo') plt.show()