title: save and plot multiple datasets using python
body: <p>I ran in one more problem - I have multiple files with the following format:</p>
  
  <p>Freq A B</p>
  
  <p>1000 1.2 0.0014</p>
  
  <p>100 1.2 0.00013</p>
  
  <p>10 1.2 0.0012</p>
  
  <p>all files are in the same folder; up to now I am able to read all files, do the calculations I want, and then save one large file with all the needed data (see below for code)</p>
  
  <p>before I save the data I want to:</p>
  
  <p>Break the data into the number of the original files, with the new data, and use the same name as the input name (N in the code is the number of lines per file, I use that to be able to identify how many files I have from the total number of lines)</p>
  
  <p>and, to plot all different data in one plot (assume that I have 3 files like the above, I want a plot with with 3 lines, all on the same plot) - I cannot seem to be able to do that since all my tries give me just one single line</p>
  
  <p><strong>* UPDATE - I can read the data, and putting everithing in the first loop, then I can go over all data - now I want to automate the saving function, but the code (see below a simplified version) saves only one data set (maybe overwrites the text files?)
  *</strong> UPDATE 2 - this now works - needed to add the save function in the 2nd loop</p>
  
  <pre><code>import os
  import numpy as np
  
  datadirectory = '/media/data'
  os.chdir( datadirectory)
  
  listing = os.listdir(datadirectory) 
  my_array=np.zeros(shape=(0,3))
  
  for infile in listing: 
     dataset = open(infile).readlines()
     data = np.genfromtxt(dataset, usecols=(0,1,2))
     my_array = np.vstack((my_array, data))
     lta= my_array
  </code></pre>
  
  <h3>SOME PROCESSING HERE - lta now has 5 columns</h3>
  
  <pre><code>   Results=np.column_stack((lta[:,0], lta[:,1], lta[:,2], lta[:,3], lta[:,4]))
     for i in listing:
         date = i
         np.savetxt((os.path.join(resultpath, date)) + '.txt', Results, fmt='%s', delimiter='\t') 
     my_array = np.vstack((my_array, Results))
  </code></pre>
  
  <h1>Plot data - IN my_array array I have all data, and every N rows (given number) I have a different dataset - Iwant to plot all data in the same graph, and every N rows I want to change symbol color</h1>
  
  <pre><code>import matplotlib.pylab as plt
  
  plt.figure(figsize=(10,5))
  #graph_axes = plt.subplot(N,2,1)
  graph = plt.semilogx(my_array[:,0], my_array[:,2])
  plt.ylim(0, 25)
  plt.xlim(0.1, 1000)
  plt.show()
  plt.savefig(os.path.join(resultpath, 'image.png'))
  </code></pre>
  
  <p>any help / guidance is appreciated!</p>