title: Plotting Multiple Plots on a single figure from within a for loop - Python
body: <p>I have reviewed the response to this question: <a href="https://stackoverflow.com/questions/38727364/how-would-i-iterate-over-a-list-of-files-and-plot-them-as-subplots-on-a-single-f">How would I iterate over a list of files and plot them as subplots on a single figure?</a></p>
  
  <p>But am none the wiser on how to achieve my goal. I would like to plot multiple data sets, with differing x axes, onto a single figure in Python. I have included a snippet of my code below, which performs an FFT on a dataset, then calculates 3 Butterworth filter outputs. Ideally I would like to have all  plotted on a single figure, which I have attempted to achieve in the code below.
  The for loop calculates the 3 Butterworth filter outputs, the code above - the FFT and the code directly below attempts to append the FFT curve and sqrt(0.5) line to the previously generated plots for display.</p>
  
  <p>Any Direction or advice would be appreciated.</p>
  
  <pre><code>"""Performs a Fast Fourier Transform on the data specified at the base of the code"""
  def FFT(col):
      x = io2.loc[1:,'Time']
      y = io2.loc[1:,col]
      # Number of samplepoints
      #N = 600
      N = pd.Series.count(x)
      N2 = int(N/2)
      # sample spacing
      #T = 1.0 / 800.0
      T = 1/(io2.loc[2,'Time'] - io2.loc[1,'Time'])
      #x = np.linspace(0.0, N*T, N)
      #y = np.sin(50.0 * 2.0*np.pi*x) + 0.5*np.sin(80.0 * 2.0*np.pi*x)
      yf = scipy.fftpack.fft(y)
      xf = np.linspace(0.0, 1.0/(2.0*T), N2)
  
  fig=plt.figure()
  plt.clf()
  i=1
  for order in [3, 6, 9]:
      ax=fig.add_subplot(111, label="order = %d" % order)
      b, a = butter_lowpass(cutoff, fs, order=order)
      w, h = freqz(b, a, worN=2000)
  
      ax.plot((fs * 0.5 / np.pi) * w, abs(h))
      i=i+1
  
  ax4=fig.add_subplot(111, label='sqrt(0.5)', frame_on=False)
  ax5=fig.add_subplot(111, label="FFT of "+col, frame_on=False)
  
  ax4.plot([0, 0.5 * fs], [np.sqrt(0.5), np.sqrt(0.5)], '--')
  ax5.plot(xf, 2.0/N * np.abs(yf[:N2]))
  plt.xlabel('Frequency (Hz)')
  plt.ylabel('Gain')
  plt.grid(True)
  plt.legend(loc='best')
  
  #fig, ax = plt.subplots()
  #ax.plot(xf, 2.0/N * np.abs(yf[:N2]), label="FFT of "+col)
  plt.axis([0,5000,0,0.1])
  #plt.xlabel('Frequency (Hz)')
  #plt.ylabel('Amplitude (mm)')
  #plt.legend(loc=0)
  plt.show()
  
  return
  </code></pre>
  
  <p>Kind Regards,</p>