title: Matplotlib: enforce equal size (height) of subplots?
body: <p>I have a figure containing three subplots. The first subplot is an image (<code>imshow</code>), while the other two are distributions (<code>plot</code>).</p>
  
  <p>Here's the code:</p>
  
  <pre><code># collects data
  imgdata = ...      # img of shape  (800, 1600, 3)    
  x = ...            # one 1600-dimensional vector
  y = ...            # one  800-dimensional vector
  
  # create the figure 
  f = plt.figure()    
  
  # create subplots   
  subplot_dim = (1, 3)
  p_img = plt.subplot2grid(subplot_dim, (0, 0), aspect="auto")
  p_x = plt.subplot2grid(subplot_dim, (0, 1), aspect="auto")
  p_y = plt.subplot2grid(subplot_dim, (0, 2), aspect="auto")
  
  p_img.imshow(imgdata, interpolation="None")
  p_x.plot(x)         
  p_y.plot(y)         
  
  
  # save figure       
  f.set_size_inches(21.0, 12.0)
  f.savefig("some/path/image.pdf", dpi=80)
  </code></pre>
  
  <p>My problem is, that the two subplots <code>p_x</code>, <code>p_y</code> <em>always</em> have a greater height than the image subplot <code>p_img</code>.</p>
  
  <p>Thus, the result always looks like this:</p>
  
  <pre><code>                  ###############   ###############   
                    #             #   #  *****      #
                    #        *****#   # *     *     #
  ###############   #     ***     #   # *      *    #
  #             #   #    *        #   # *        *  #
  #    image    #   #   *         #   #*           *#
  #             #   #***          #   #*           *#
  ###############   ###############   ###############
       p_img              p_x               p_y
  </code></pre>
  
  <p><strong>How can I enforce an equal size</strong> (or at least <em>height</em>) of <code>p_img</code>, <code>p_x</code> and <code>p_y</code>?</p>
  
  <p><strong>EDIT:</strong> Here is a <strong>simple example code</strong> that generates random data and uses <code>plt.show()</code> instead of saving a figure. However, one can easily see the same behaviour there: the image is much smaller (height) than the other subplots:</p>
  
  <pre><code>from matplotlib import pyplot as plt 
  from matplotlib import image as mpimg
  import numpy as np
  
  imgdata = np.random.rand(200, 400, 3)  
  x = np.random.normal(loc=100.0, scale=20.0, size=400)
  y = np.random.normal(loc=150.0, scale=15.0, size=200) 
  
  # create the figure
  f = plt.figure()
  
  # create subplots
  subplot_dim = (1, 3)
  p_img = plt.subplot2grid(subplot_dim, (0, 0), aspect="auto")
  p_x = plt.subplot2grid(subplot_dim, (0, 1), aspect="auto")
  p_y = plt.subplot2grid(subplot_dim, (0, 2), aspect="auto")
  
  p_img.imshow(imgdata, interpolation="None")
  p_x.plot(x)
  p_y.plot(y)
  
  
  # save figure
  plt.show()
  </code></pre>