title: Matplotlib bbox_inches='tight' adjust only height
body: <p>I would like to reduce the whitespace around my figures but without decreasing the figure width. In the example below I would generate a figure of specific width and height but size the axis is equal (which I would like to maintain) the resulting plot contains a lot of whitespace on both the top and the bottom. Saving the figure using <code>bbox_inches='tight'</code> reduces this whitespace but also cuts sometimes on some of the width which I would like to avoid. Any ideas how I would be able to adjust the height to match the axis without influencing the width?</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  x=np.linspace(0,68,35)
  y=np.linspace(0,34,35)
  X, Y = np.meshgrid(x, y)
  Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
  Z2 = plt.mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
  Z = 10 * (Z1 - Z2)
  Z = np.ma.array(Z)
  print Z.shape
  fig = plt.figure(figsize=(2, 2), dpi=400)
  ax=(fig.add_subplot(111, aspect='equal'))
  
  
  CS = plt.contourf(x, y, Z, 10,cmap=plt.cm.bone)
  
  plt.show()
  </code></pre>
  
  <p>Below please find the figure (white background) placed over a brown surface
  to better appreciate its extent with respect to the image plotted inside the figure/</p>
  
  <p><a href="https://i.stack.imgur.com/ALnly.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ALnly.png" alt="enter image description here"></a></p>