title: Plotting in Python via matplotlib.pyplot (calculate the area)
body: <p>I have a question \ problem. I need to plot the graph by the numbers that I got from the file (which I did) and then I need to draw a line connecting start and end, and calculate the area that between these two lines. I try to make a lot of variations, but i have no idea how I can make it.. </p>
  
  <p>I'm trying do it via matplotlib.pyplot library</p>
  
  <p><img src="https://i.stack.imgur.com/yp8zJ.jpg" alt="enter image description here"></p>
  
  <p>Here the 'figure' whitch I should to get after add 'connection line between beginning and and' and now I need calcutale square between black line and blue. 
  PS the black one is kind of straight :)</p>
  
  <p><img src="https://i.stack.imgur.com/dftoD.jpg" alt="enter image description here"></p>
  
  <p>Here is soure of code, and my data file... 
  <a href="http://pastebin.com/g40bAzPR" rel="nofollow noreferrer">http://pastebin.com/g40bAzPR</a></p>
  
  <pre><code>#!/path/to/python -tt
  
  # numerical data
  # python GraphicalPart.py ../dataFile.txt
  
  import sys
  import matplotlib.pyplot as plt
  import numpy as np
  
  def startDivide(fileName):
   for i in range(1,2):
      inputFile = open(fileName)
      outputFile = open(fileName + "_" + str(i) + "_out.csv", "w")
      floatList = []
      for line in inputFile.readlines():
          data = line.split(" ")
          string = data[i]
          if string.startswith('-'): #remove '-'
              string = string[1:]
          floatList.append(float(string))
  
      floatList.sort() #sorting the list of data
  
      for item in floatList:
          outputFile.write("%s\n" % item)
  
      outputFile.close() 
      inputFile.close()
  
      data1=np.genfromtxt(fileName + "_" + str(i) + '_out.csv', skip_header=1)
      plt.plot(data1) 
      plt.savefig(fileName + "_" + str(i) + "_.png")
      plt.clf()
  
  def main():
   if len(sys.argv) != 2:
    print "Not enough arguments. *_data.txt file only!"
   else:
    startDivide(sys.argv[1])
  
  if __name__ == "__main__":
   main()
  </code></pre>