Matplotlib table 落在绘图区域之外

Matplotlib table falls outside plot area

我在使用 Matplotlib 的地块中有一个 table,并且 table 超出了地块区域。有没有办法避免这种情况发生,也许使用偏移量或类似的方法?

import matplotlib.pylab as plt

plt.figure()
ax=plt.gca()

col_labels=['col1','col2','col3']
row_labels=['row1','row2','row3']
table_vals=[[11,12,13],[21,22,23],[31,32,33]]
the_table = plt.table(cellText=table_vals,
                  colWidths = [0.1]*3,
                  rowLabels=row_labels,
                  colLabels=col_labels,
                  loc='center left')
plt.text(12,3.4,'Table Title',size=8)


plt.show()

添加一个bbox参数,这样就可以控制准确的位置,例如:

plt.table(cellText=table_vals,
                  colWidths = [0.1]*3,
                  rowLabels=row_labels,
                  colLabels=col_labels,
                  loc='center left',
                  bbox=[0.25, -0.5, 0.5, 0.3])

这里是对应的documentation for table and the one for bbox.