You can do it with
import numpy as np
import matplotlib.pyplot as plt
data = np.array([[0,1,1,1], [1,0,0,1], [1,1,1,0], [0,0,0,1]])
x,y = np.argwhere(data == 1).T
plt.scatter(x,y)
plt.show()
However, when you just want to render a 4x4 array, you can use matshow
plt.matshow(data)
plt.show()
source
share