以下代码
from life import Life
import matplotlib.pyplot as plt
import numpy as np
dim_row = 20
dim_col = 20
data = [ [ 0 * dim_col for i in range(dim_col)] * dim_row for j in range(dim_row) ]
from random import randint
for i in range(dim_row):
for j in range(dim_col):
data[i][j] = randint(0,1)
# print(data)
life = Life(initial=data)
fig, ax = plt.subplots()
ax.imshow(life._initial)
for i in range(100):
ax.cla()
ax.imshow(life.next_generation())
ax.adjustable='datalim'
ax.share=True
生成以下图像
我要修复图像-使其清晰。任何帮助表示赞赏。