How to set size for scatter plot
<p>I have three lines setting a plot. I expect the size of the pic.png to be 640x640 pixels. But I got 800x800 picture. </p>

<pre><code>plt.figure(figsize=(8, 8), dpi=80)
plt.scatter(X[:],Y[:])
plt.savefig('pic.png')
</code></pre>

<p>BTW I have no problem setting size with object-oriented interface but I need to use pyplot style.</p>

<p>The following code produces a 576x576 PNG image in my machine:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.random.rand(10)

plt.figure(figsize=(8, 8), dpi=80)
plt.scatter(x, y)
plt.savefig('pic.png')
</code></pre>

<p>Shifting <code>dpi=80</code> to the <code>plt.savefig</code> call correctly results in a 640x640 PNG image:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.random.rand(10)

plt.figure(figsize=(8, 8))
plt.scatter(x, y)
plt.savefig('pic.png', dpi=80)
</code></pre>

<p>I can't offer any explanation as to why this happens though.</p>

python matplotlib