plotting – How to make a discrete circle in a 2d array?

If you really want to replace parts in an array, here’s how I’d do it.

array = ConstantArray(0, {height, width});
{x0,y0}={20,40};
r=5;
array=ReplacePart(array, {i_, j_} /; (i - x0)^2 + (j - y0)^2 < r^2 :> 1);
ArrayPlot(array)

enter image description here

Otherwise I’d just go ahead and generate the array how I want it, using a function defined to decide if a given coordinate belongs in the circle.:

inCircle({i_, j_}, r_, {x_, y_}) := 
  If((i - x)^2 + (j - y)^2 < r^2, 1, 0);

 array=Table(inCircle({i, j}, 5, {3, 2}), {i, -10, 10, 1}, {j, -10, 10, 1});
  ArrayPlot@array

enter image description here

One benefit of this method is you can change the resolution pretty easily.

array=Table(inCircle({i, j}, 5, {3, 2}), {i, -10, 10, 0.1}, {j, -10, 10, 0.1});
      ArrayPlot@array

enter image description here