title: Changing the color of Line plots on each iteration of a for loop
body: <p><strong>EDITED</strong></p>
  <p><strong>What I am starting with :</strong> I have multiple .xyz files for profiles ranging from</p>
  <blockquote>
  <p><em>1982_1_Final.xyz</em> -  <em>1982_54_Final.xyz</em>
  and such from 1982-2012</p>
  </blockquote>
  <p>with Elevation/depth and Distance data columns to be able to plot horizontal profiles.</p>
  <p><strong>The Aim :</strong> I want to compare let say profile 25 for all years from 1982 until 2012,</p>
  <blockquote>
  <p>so 1982_25_Final.xyz, 1983_25_Final.xyz, 1984_25_Final.xyz.....
  2012_25_Final.xyz</p>
  </blockquote>
  <p><strong>What I have so far :</strong></p>
  <pre><code>import os
  import pandas as pd
  import matplotlib.pyplot as plt
  
  path = 'C:/Clayton/lines/profiles_aufmod'
  os.chdir(path)
  print(os.getcwd())
  
  # Initiate figure
  NUM_COLORS = 30
  linestyle  = ['solid', 'dashed', 'dashdot', 'dotted']
  NUM_STYLES = len(linestyle)
  cm = plt.get_cmap('gist_rainbow')
  fig = plt.figure()
  ax = fig.add_subplot(111)
  
  for directory_2, subdir_2, file_2 in os.walk(path):
  
      for ind, filename_2 in enumerate(file_2, 1):
          if filename_2.endswith(&quot;25_Final.xyz&quot;):
  
              os.chdir(directory_2)
              Profile_raw_2 = pd.read_csv(
              filename_2, delimiter=',', names=[&quot;lat&quot;, &quot;lon&quot;, &quot;prof&quot;, &quot;elev&quot;,&quot;dist&quot;])
  
              lines = ax.plot(Profile_raw_2.iloc[:, 4], Profile_raw_2.iloc[:, 3], label=filename_2[0:29])
  
              for i in range(NUM_COLORS):
  
                   lines[0].set_color(cm(i // NUM_STYLES * float(NUM_STYLES) / NUM_COLORS))
                   lines[0].set_linestyle(linestyle[i % NUM_STYLES])
  
      os.chdir(path)
  plt.show()
  </code></pre>
  <p><strong>Problems I am facing :</strong> The nesting of the for loop is somehow wrong and I get all plots in one color and one linestyle, I cannot figure out the right order for the for loops here to get the desired output. <a href="https://i.stack.imgur.com/jag7S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jag7S.png" alt="Output_image" /></a></p>
  <p><strong>What I need help with :</strong></p>
  <ol>
  <li>Nesting the for loop in the right order</li>
  <li>Making sure the colors are different for each year.</li>
  <li>How to change the colormap before hand to possibly get a sequential
  type which is good to indicate a yearly changing data.</li>
  <li>Any recommendations for such a plot?</li>
  </ol>
  <p><strong>Thank you in advance and sorry if there are some obvious mistakes, I am fairly new to python.</strong></p>