title: matplotlib: multiple plots on one figure
body: <p>I have some code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  def print_fractures(fractures):
      xpairs = []
      ypairs = []
      plt.figure(2)
      plt.subplot(212)
      for i in range(len(fractures)):
          xends = [fractures[i][1][0], fractures[i][2][0]]
          yends = [fractures[i][1][1], fractures[i][2][1]]
          xpairs.append(xends)
          ypairs.append(yends)
      for xends,yends in zip(xpairs,ypairs):
          plt.plot(xends, yends, 'b-', alpha=0.4)
      plt.show()
  
  
  def histogram(spacings):
      plt.figure(1)
      plt.subplot(211)
      plt.hist(spacings, 100)
      plt.xlabel('Spacing (m)', fontsize=15)
      plt.ylabel('Frequency (count)', fontsize=15)
      plt.show()
  
  histogram(spacings)    
  print_fractures(fractures)
  </code></pre>
  
  <p>This code will produce the following output:
  <img src="https://i.stack.imgur.com/IRpw9.png" alt="Fig1"></p>
  
  <p>My questions are:</p>
  
  <p>1) Why are two separate figures being created? I thought the subplot command would combine them into one figure. I thought it might be the multiple plt.show() commands, but I tried commenting those out and only calling it once from outside my functions and I still got 2 windows.</p>
  
  <p>2) How can I combine them into 1 figure properly? Also, I would want figure 2 axes to have the same scale (i.e. so 400 m on the x axis is the same length as 400 m on the y-axis). Similarly, I'd like to stretch the histogram vertically as well - how is this accomplished?</p>