title: Matplotlib plot creation with loop
body: <p>I have working code that produces the exact graph I'm looking for. However, It's hard coded (especially the legend) and I assume there is a way to do the same graph but in a loop.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  raw_data = {'Time':       [1,    2,    3,    4,    5,    6 ,  7,    8,   9,      10],
          'Drug 1':     [23.4, 32.5, 45.6, 46.1, 47.8, 50.1, 51.2, 53.2, 54.5, 55.0],
          'Drug 2':    [10.4,  12.5, 13.7, 13.8, 14.0, 15.6, 17.7, 23.2, 20.4, 19.5], 
          'Drug 3':    [0.4,   1.5,  2.6,  3.7,  4.8,  5.9,  6.2,  8.7,  12.8, 13],
          'Drug 4':    [45,    47,   48,   50,   51,     52,   55,  60,   61,   67],
          'Drug 5':    [17,    21,    20, 20,    20,     24,    26,  28, 29,   30]}
  
  
  df = pd.DataFrame(raw_data)
  
  plt.errorbar(x = df['Time'], y = df['Drug 1'], yerr=None, linestyle = "--")
  plt.errorbar(x = df['Time'], y = df['Drug 2'], yerr=None, linestyle = "--")
  plt.errorbar(x = df['Time'], y = df['Drug 3'], yerr=None, linestyle = "--")
  plt.errorbar(x = df['Time'], y = df['Drug 4'], yerr=None, linestyle = "--")
  plt.errorbar(x = df['Time'], y = df['Drug 5'], yerr=None, linestyle = "--")
  
  plt.legend(['Drug 1', 'Drug 2', 'Drug 3', 'Drug 4', 'Drug 5'], loc = 2)
  
  plt.ylabel('Tumor Size')
  plt.xlabel('Time in Years')
  
  plt.title('Effect on Treatment')
  plt.grid()
  
  plt.show()
  </code></pre>
  
  <p>I know having five lines all calling <code>plt.errorbar</code> is not optimal, also hard coding the legend like I am, also is sub-optimal. </p>
  
  <p>I have tried to start from scratch a little by using: </p>
  
  <pre><code>for x in df:
      print(x)
  </code></pre>
  
  <p>...but that includes the $Time$ column, so I'm not sure how to always make time the x axis and then iterate over the rest of the columns for the y. </p>