title: How to change size of figures drawn in matplotlib without centering?
body: <p>I'm plotting sequential images of a dot going round in a circle. I'm trying to output square images using <code>plt.savefig()</code>. The default output has dimensions 640 × 480 (not square).</p>
  
  <p>Using <code>figure(figsize = (x_size,y_size))</code>, I can specify the number of inches along each dimension in the output of <code>plt.savefig()</code>, as discussed in <a href="https://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib">How do you change the size of figures drawn with matplotlib?</a>. However this centres the image so that my dot always appears in the centre of the frame. </p>
  
  <p>To be more clear, using the following code I can output square images (500 × 500) of dot going round in circle :</p>
  
  <pre><code>for i in range(N):
    x = np.cos(w * t)
    y = np.sin(w * t)
    t += dt
    plt.xlim(-2, 2)
    plt.ylim(-2, 2)
    fig = plt.figure(figsize=(5, 5))
    plt.scatter(x, y, marker='o', c='black', s=100)
    plt.axis('off')
    plt.savefig("./fig" + str(i) + ".png")
  </code></pre>
  
  <p>However, the image is shifted along the x, y axis such that the dot always appears in the centre of the image. </p>
  
  <p>How can I output square images without centering the image?</p>
  
  <p>EDIT: Solution is to define <code>fig = plt.figure(figsize=(5, 5))</code> before setting <code>plt.xlim(-2, 2)</code> and <code>plt.ylim(-2, 2)</code>.</p>