title: matplotlib: combine different figures and put them in a single subplot sharing a common legend
body: <p>We have a code that <a href="https://www.dropbox.com/s/g646f1wghktrl1b/matplotlib-combine-different-figures-and-put-them-in-a-single-subplot-sharing-a.zip" rel="noreferrer">creates figures from input.txt files</a>. We need to combine 2 of these figures in a single subplot. The data from figure1 will be plotted in the left subplot and from figure2 in the right subplot, sharing the same legend and witht he same scale in axes x and y:</p>
  
  <p><img src="https://i.stack.imgur.com/6fyGy.png" alt="enter image description here"></p>
  
  <p>Here there is some example data:</p>
  
  <pre><code>x  = [ 1, 2, 3, 5, 10, 100, 1000 ]
  y1 = [ 1, 0.822, 0.763, 0.715, 0.680, 0.648, 0.645 ]
  y2 = [ 1, 0.859, 0.812, 0.774, 0.746, 0.721, 0.718 ]
  
  import matplotlib.pyplot as plt
  # mode 01 from one case
  fig1 = plt.figure()
  ax1 = fig1.add_subplot(111)
  ax1.plot( x, y1, label='mode 01' )
  # mode 01 from other case
  fig2 = plt.figure()
  ax2 = fig2.add_subplot(111)
  ax2.plot( x, y2, label='mode 01' )
  </code></pre>
  
  <hr>
  
  <p>EDIT: the method suggested by @nordev works. Now it would be really convenient to pass the ax1 and ax2 objects to the new figure, since they have much more information. <a href="https://stackoverflow.com/questions/6309472/matplotlib-can-i-create-axessubplot-objects-then-add-them-to-a-figure-instance#comment18919455_6309636">It seems that there is no straightforward way to achieve that</a>. </p>
  
  <p>The <a href="https://www.dropbox.com/s/g646f1wghktrl1b/matplotlib-combine-different-figures-and-put-them-in-a-single-subplot-sharing-a.zip" rel="noreferrer">real case has been made available here</a>. To make it work, please run <code>plot_both.py</code>.</p>
  
  <hr>
  
  <p>EDIT2: it was easier to change the routine that reads the input.txt files. <a href="https://www.dropbox.com/s/ekywe8m3f8vh6j4/matplotlib-combine-different-figures-and-put-them-in-a-single-subplot-sharing-a-new.zip" rel="noreferrer">Now it supports multiple plots</a>. But the question is still valid because it would be great to treat the <code>AxesSubplot</code> as an easily interchangeable object among different figures, subplots and so forth...</p>