import matplotlib.pyplot as plt
import numpy as np
# 0〜2の数字を色に対応させる
pixels = np.array([
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,2,3,2,1,0,0,0,0,0,0],
[0,0,0,0,0,1,3,6,7,6,3,1,0,0,0,0,0],
[0,0,0,0,1,4,1,7,1,7,1,4,1,0,0,0,0],
[0,0,0,1,5,6,3,9,6,9,3,6,5,1,0,0,0],
[0,0,1,6,3,5,9,9,5,9,9,5,3,6,1,0,0],
[0,1,7,1,5,8,4,4,4,4,4,8,5,4,7,1,0],
[1,8,9,4,5,8,7,3,3,3,7,8,9,7,3,8,1],
])
# カラーマップを自作(0=白, 1=青, 2=赤)
from matplotlib.colors import ListedColormap
cmap = ListedColormap(["white","red", "blue", "green", "yellow", "black", "pink", "purple", "orange", "gray",])
plt.imshow(pixels, cmap=cmap, interpolation='nearest')
plt.axis('off')
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: