I'm plotting sequential images of a dot going round in a circle. I'm trying to output square images using plt.savefig()
. The default output has dimensions 640 × 480 (not square).
Using figure(figsize = (x_size,y_size))
, I can specify the number of inches along each dimension in the output of plt.savefig()
, as discussed in How do I change the size of figures drawn with Matplotlib?. However this centres the image so that my dot always appears in the centre of the frame.
To be more clear, using the following code I can output square images (500 × 500) of dot going round in circle :
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")
However, the image is shifted along the x, y axis such that the dot always appears in the centre of the image.
How can I output square images without centering the image?