title: draw matrix as a table in python
body: <p>I am trying to generate a data matrix with python and wish to draw it as a table.
  From IPython, I found a display api and it can display the matrix as a table. but I still prefer:
  1. remove the row index col and col index row.
  2. the data grid should split evenly.</p>
  
  <p>I am think about matplotlib but not sure how to do it.I wish to do it in the same script so no need to paste it here and there! </p>
  
  <pre><code>%matplotlib inline
  import numpy as np
  import pandas as pd
  from IPython.display import display, HTML
  import matplotlib.pyplot as plt
  print pd.__version__
  
  row = 6
  col = row
  matrix = np.zeros((row, col))
  for i in range(row):
      for j in range(col):
          if i == 0:
              matrix[i][j] = 1
          else:
              matrix[i][j] = matrix[i-1][j] + matrix[i][j-1]
  df = pd.DataFrame(matrix)
  display(df)
  </code></pre>
  
  <p>Current output is:</p>
  
  <p><a href="https://i.stack.imgur.com/BH63Xm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BH63Xm.png" alt="enter image description here"></a></p>
  
  <h3>Updated</h3>
  
  <p>According to Brat's comments, I have updated my code for referenc:</p>
  
  <pre><code>%matplotlib inline
  import numpy as np
  import pandas as pd
  from IPython.display import display, HTML
  import matplotlib.pyplot as plt
  
  row = 7
  col = row
  matrix = np.zeros((row, col))
  matrix = matrix.astype(int)
  for i in range(row):
      for j in range(col):
          if i == 0:
              matrix[i][j] = 1
          else:
              matrix[i][j] = matrix[i-1][j] + matrix[i][j-1]
  df = pd.DataFrame(matrix)
  #display(df)
  
  w = 5
  h = 5
  plt.figure(1, figsize=(w, h))
  tb = plt.table(cellText=matrix, loc=(0,0), cellLoc='center')
  
  tc = tb.properties()['child_artists']
  for cell in tc: 
      cell.set_height(1.0/row)
      cell.set_width(1.0/col)
  
  ax = plt.gca()
  ax.set_xticks([])
  ax.set_yticks([])
  
  plt.show()
  </code></pre>
  
  <p>Output as bleow:</p>
  
  <p><a href="https://i.stack.imgur.com/3JVbr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3JVbr.png" alt="enter image description here"></a></p>