You want to loop over the values in grid
, and use ax.text
to add the label to the plot.
Fortunately, for 2D arrays, numpy
has ndenumerate
, which makes this quite simple:
for (j,i),label in np.ndenumerate(grid):
ax1.text(i,j,label,ha="center",va="center")
ax2.text(i,j,label,ha="center",va="center")