Generating points on a circle
<pre><code>import random
import math
import matplotlib.pyplot as plt


def circle():
    x = []
    y = []
    for i in range(0,1000):
        angle = random.uniform(0,1)*(math.pi*2)
        x.append(math.cos(angle));
        y.append(math.sin(angle));
    plt.scatter(x,y)
    plt.show()
circle()
</code></pre>

<p>I've written the above code to draw 1000 points randomly on a unit circle. However, when I run this code, it draws an oval for some reason. Why is this?</p>

<p><a href="http://i.stack.imgur.com/vxsbK.png" rel="nofollow"><img src="http://i.stack.imgur.com/vxsbK.png" alt="enter image description here"></a></p>

<p>It is a circle -- The problem is that the aspect ratio of your axes is not 1 so it looks like an oval when you plot it.  To get an aspect ratio of 1, you can use:</p>

<pre><code>plt.axes().set_aspect('equal', 'datalim')  # before `plt.show()`
</code></pre>

<p>This is highlighted in a <a href="http://matplotlib.org/examples/pylab_examples/equal_aspect_ratio.html" rel="nofollow">demo</a>.</p>

python matplotlib