I want to make a plot of gcd function over some region of integers. So basically I want a dot over (x=a,y=b) at z=gcd(x,y) when 0<a<n and 0<b<n.
This code is naive and doesn't work
# make data
X, Y = np.meshgrid(np.linspace(1, 3, 3), np.linspace(1, 3, 3))
#Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
Z = gcd(X,Y)
# plot
fig, ax = plt.subplots()
ax.imshow(Z)
On the other hand the following code give me an array with gcd values over some integers
from fractions import gcd
matrix = [[gcd(i,j) for i in range(20)] for j in range(20)]
print(np.matrix(matrix))
What would be the correct way to obtain a scatter plot of the gcd function?