title: How to plot data from multiple files in a loop
body: <p>I have a more than 1000 <code>.csv</code> files (data_1.csv......data1000.csv), each containing X and Y values!</p>
  <pre><code>x1  y1   x2  y2
  5.0 60  5.5 500
  6.0 70  6.5 600
  7.0 80  7.5 700
  8.0 90  8.5 800
  9.0 100 9.5 900
  </code></pre>
  <hr />
  <p>I have made a subplot program in python which can give two plots (plot1 - X1vsY1, Plot2 - X2vsY2) at a time using one file.</p>
  <p>I need help in looping all the files, (open a file, read it, plot it, pick another file, open it, read it, plot it, ... until all the files in a folder get plotted)</p>
  <p>I have the following code:</p>
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  
  df1=pd.read_csv(&quot;data_csv&quot;,header=1,sep=',')
  fig = plt.figure()
  plt.subplot(2, 1, 1)
  plt.plot(df1.iloc[:,[1]],df1.iloc[:,[2]])
  
  plt.subplot(2, 1, 2)
  plt.plot(df1.iloc[:,[3]],df1.iloc[:,[4]])
  
  plt.show()
  </code></pre>
  <p>How can this be accomplished more efficiently?</p>