title: Fix figure size when using matplotlib
body: <p>I want to fix figure size when using matplotlib. However, it never works.</p>
  
  <p>The following codes should produce a figure of size 9 cm in width and 7 cm in height. However, when saving figure using savefig, figure size changes. However to fix this?</p>
  
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  
  x = [30, 40, 50, 60, 70, 80, 90, 100]
  
  y = [6,  7,  8,  9,  10, 11, 12, 13]
  
  figw, figh = 9 / 2.54, 7 / 2.54
  
  plt.figure(figsize=(figw, figh)) 
  
  plt.plot(x, y, 'r-o', label='Legend')
  
  plt.xlabel('X Lable')
  
  plt.ylabel('Y Label')
  
  plt.legend(loc=(0.05, 0.83))
  
  plt.tight_layout()
  
  plt.show()
  
  plt.savefig(fname='fig.png', dpi=600, quality=95, bbox_inches='tight', pad_inches=0)
  </code></pre>