title: Matplotlib imshow/matshow display values on plot
body: <p>I am trying to create a 10x10 grid using either <code>imshow</code> or <code>matshow</code> in Matplotlib. The function below takes a numpy array as input, and plots the grid. However, I'd like to have values from the array also displayed inside the cells defined by the grid. So far I could not find a proper way to do it. I can use <code>plt.text</code> to place things over the grid, but this requires coordinates of each cell, totally inconvenient. Is there a better way to do what I am trying to accomplish?</p>
  
  <p>Thanks!</p>
  
  <p>NOTE: The code below does not take the values from the array yet, I was just playing with <code>plt.text</code>.</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib import colors
  
  board = np.zeros((10, 10))
  
  def visBoard(board):
     cmap = colors.ListedColormap(['white', 'red'])
     bounds=[0,0.5,1]
     norm = colors.BoundaryNorm(bounds, cmap.N)
     plt.figure(figsize=(4,4))
     plt.matshow(board, cmap=cmap, norm=norm, interpolation='none', vmin=0, vmax=1)
     plt.xticks(np.arange(0.5,10.5), [])
     plt.yticks(np.arange(0.5,10.5), [])
     plt.text(-0.1, 0.2, 'x')
     plt.text(0.9, 0.2, 'o')
     plt.text(1.9, 0.2, 'x')
     plt.grid()
  
     visBoard(board)
  </code></pre>
  
  <p>Output:</p>
  
  <p><img src="https://i.stack.imgur.com/IldLi.png" alt="enter image description here"></p>