I think that you can just use the plt.text for those purposes. The code below uses it to obtain the result you want.
import matplotlib.pyplot as plt import numpy as np from matplotlib import rcParams rcParams['font.family'] = 'serif' rcParams['font.size'] = 16 A = [[1, 3, 4, 5, 6, 7], [3, 3, 0, 7, 9, 2], [1, 3, 4, 5, 6, 6]] X = ["A", "B", "C", "E", "F", "G"] Y = ["R", "S", "T"] m = len(Y) n = len(X) plt.figure(figsize=(n + 1, m + 1)) for krow, row in enumerate(A): plt.text(5, 10*krow + 15, Y[krow], horizontalalignment='center', verticalalignment='center') for kcol, num in enumerate(row): if krow == 0: plt.text(10*kcol + 15, 5, X[kcol], horizontalalignment='center', verticalalignment='center') plt.text(10*kcol + 15, 10*krow + 15, num, horizontalalignment='center', verticalalignment='center') plt.axis([0, 10*(n + 1), 10*(m + 1), 0]) plt.xticks(np.linspace(0, 10*(n + 1), n + 2), []) plt.yticks(np.linspace(0, 10*(m + 1), m + 2), []) plt.grid(linestyle="solid") plt.savefig("Table.png", dpi=300) plt.show()
And, you get
