Fix: rename grand_rectangle -> grand_carre

This commit is contained in:
Bertrand Benjamin 2021-06-25 07:57:00 +02:00
parent 4eb6e0aedb
commit bed10d85fe

View File

@ -23,6 +23,26 @@ def trim_axs(axs, N):
return axs[:N] return axs[:N]
def draw_image(grid, ax):
hight = len(grid)
lenght = len(grid[0])
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
ax.imshow(grid, cmap="binary")
ax.hlines(
y=np.arange(0, hight) + 0.5,
xmin=np.full(lenght, 0) - 0.5,
xmax=np.full(lenght, hight) - 0.5,
color="gray",
)
ax.vlines(
x=np.arange(0, lenght) + 0.5,
ymin=np.full(lenght, 0) - 0.5,
ymax=np.full(lenght, hight) - 0.5,
color="gray",
)
return ax
def grid_to_image(grids, filename): def grid_to_image(grids, filename):
""" """ """ """
plt.clf() plt.clf()
@ -31,23 +51,7 @@ def grid_to_image(grids, filename):
axs = plt.figure(constrained_layout=True).subplots(n_rows, n_cols) axs = plt.figure(constrained_layout=True).subplots(n_rows, n_cols)
axs = trim_axs(axs, len(grids)) axs = trim_axs(axs, len(grids))
for ax, grid in zip(axs, grids): for ax, grid in zip(axs, grids):
# for i, grid in enumerate(grids): draw_image(grid, ax)
hight = len(grid)
lenght = len(grid[0])
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
ax.imshow(grid, cmap="binary")
ax.hlines(
y=np.arange(0, hight) + 0.5,
xmin=np.full(lenght, 0) - 0.5,
xmax=np.full(lenght, hight) - 0.5,
color="gray",
)
ax.vlines(
x=np.arange(0, lenght) + 0.5,
ymin=np.full(lenght, 0) - 0.5,
ymax=np.full(lenght, hight) - 0.5,
color="gray",
)
plt.savefig(filename) plt.savefig(filename)