title: Axes class - set explicitly size (width/height) of axes in given units
body: <p>I want to to create a figure using matplotlib where I can explicitly specify the size of the axes, i.e. I want to set the width and height of the axes bbox.</p>
  
  <p>I have looked around all over and I cannot find a solution for this. What I typically find is how to adjust the size of the complete Figure (including ticks and labels), for example using <code>fig, ax = plt.subplots(figsize=(w, h))</code></p>
  
  <p>This is very important for me as I want to have a 1:1 scale of the axes, i.e. 1 unit in paper is equal to 1 unit in reality. For example, if xrange is 0 to 10 with major tick = 1 and x axis is 10cm, then 1 major tick = 1cm. I will save this figure as pdf to import it to a latex document.</p>
  
  <p><a href="https://stackoverflow.com/questions/17990845/how-to-equalize-the-scales-of-x-axis-and-y-axis-in-python-matplotlib">This question</a> brought up a similar topic but the answer does not solve my problem (using <code>plt.gca().set_aspect('equal', adjustable='box')</code> code)</p>
  
  <p>From this other <a href="https://stackoverflow.com/questions/19306510/determine-matplotlib-axis-size-in-pixels">question</a> I see that it is possible to get the axes size, but not how to modify them explicitly.</p>
  
  <p>Any ideas how I can set the axes box size and not just the figure size. The figure size should adapt to the axes size.</p>
  
  <p>Thanks!</p>
  
  <p>For those familiar with <a href="http://pgfplots.sourceforge.net/" rel="noreferrer">pgfplots</a> in latex, it will like to have something similar to the <code>scale only axis</code> option (see <a href="https://tex.stackexchange.com/questions/301594/scale-only-axis-only-for-one-axis">here</a> for example).</p>