import matplotlib
color1=(1,1,1)
color2=(247/255,220/255,111/255)
mat=np.zeros((8,8))
for i in range(8):
for j in range(8):
if (i+j)%2==0:
mat[i,j]=1
else:
mat[i,j]=-1
my_cmap=matplotlib.colors.LinearSegmentedColormap.from_list('my_camp',[color1,color2],2)
cs=plt.imshow(mat,cmap=my_cmap)
plt.xticks(np.linspace(0,8,8,endpoint=False),('a','b','c','d','e','f','g','h'),fontsize=20)
plt.yticks(np.linspace(0,8,8,endpoint=False),('1','2','3','4','5','6','7','8'),fontsize=20)
plt.tick_params(bottom=False,left=False,labeltop=True,labelright=True)
plt.show()
python画棋盘
最新推荐文章于 2024-07-11 17:14:21 发布