I'm trying to make a scatter plot consisting of ~6 million points in an attempt to understand some sort of clustering.
When I try to do this in a simple scatter command, matplotlib complains about excessive memory. So I decided to plot 3000 points and then save the figure in .png format, clear the figure, load the saved .png with imread() and then overlay the next 3000 points.
I'm facing some padding issues and I do not understand how they've arisen. My code is a bit long since I'm parsing a lot of text files but below is a sample mockup code that replicates my thinking:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.xlim(0,1000)
plt.ylim(-1000,1000)
plt.scatter(400,500,marker="+",c="r")
plt.gca().set_aspect('equal')
plt.draw()
plt.savefig(r"C:\TMP\fig1.png")
plt.clf()
im = plt.imread(r"C:\TMP\fig1.png")
implot = plt.imshow(im, origin='upper', aspect='equal', extent=[0,1000,-1000,1000], zorder=0)
plt.scatter(600,500,marker="+",c="b")
plt.savefig(r"C:\TMP\fig2.png")
plt.close(fig)
The outcome is something that I don't understand how to interpret. Obviously, I do not understand the relationship between "aspect" and "extent" from imshow(). Can somebody help me with this?
Figure 1

Figure 2

I was expecting both fig1.png and fig2.png to perfectly overlay on top of another.
