I am trying to visualise a chess board in python, I have found this code online in order to be able to do so and I am trying to understand how it works. I have a rough idea of how majority of it works but I can't understand why dx and dy are these odd values? I have tried it with a value of 1 and it makes the axis for the numbers out of line?
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
dx, dy = 0.015, 0.05
x = np.arange(-4.0, 4.0, dx) # Numbers from -4 to 4 incrementing by 0.015
print(x)
y = np.arange(-4.0, 4.0, dy) # Numbers from -4 to 4 incrementing by 0.05
X, Y = np.meshgrid(x, y) # Generates an array using the values
extent = np.min(x), np.max(x), np.min(y), np.max(y) #Max and minimum X,Y values
z1 = np.add.outer(range(8), range(8)) % 2 #Generates colouring for the grid
print(z1)
plt.imshow(z1, cmap="Greys", interpolation="nearest", extent=extent, alpha=1)
plt.show()
Can someone explain please?
