Basic graphical R code draws an ellipse instead of a circle
A vectorized solution using outer (Outer Product of Arrays):

edge &lt;- 100
magicradius &lt;- .81
magicmargin &lt;- .01
width &lt;- (2*edge) + 1

x &lt;- -edge:edge
y &lt;- -edge:edge

mat &lt;- outer(x, y, function(x,y) sqrt(x^2 + y^2))
ind &lt;- mat &gt; ((magicradius-magicmargin)*edge) &amp;
       mat &lt; ((magicradius+magicmargin)*edge)
image(ind, asp=1)




The aspect ratio in image() can be set with the asp argument (see the Details section in ?plot.window)