1. Prepare the data
import matplotlib.pyplot as plt
import numpy as np
#列名
col=[]
for i in range(1,8):
col.append("Day"+str(i))
#行名
row=[]
for i in range(1,13):
row.append(i)
#表格里面的具体值
vals=np.random.rand(12,7)
Column name (day of week)
row name
2. Draw a table
plt.figure(figsize=(20,8))
tab = plt.table(cellText=vals,
colLabels=col,
rowLabels=row,
loc='center',
cellLoc='center',
rowLoc='center')
tab.scale(1,2)
plt.axis('off')
Be sure to pay attention to the last sentence of the code above, otherwise you will fail.