Python Matplotlib表格位于绘图区域之外

Python Matplotlib表格位于绘图区域之外,python,python-2.7,matplotlib,Python,Python 2.7,Matplotlib,我在使用Matplotlib的绘图中有一个表格,表格从绘图区域溢出。有没有一种方法可以避免这种情况发生,也许是通过补偿或类似的方式 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 =

我在使用
Matplotlib
的绘图中有一个表格,表格从绘图区域溢出。有没有一种方法可以避免这种情况发生,也许是通过补偿或类似的方式

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])

以下是对应于
表的
和对应于的。

添加
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])

这是对应于
表的
和对应于的。

检查
plt。表
有一个kwarg调用
bbox\u to\u anchor
。如果是,则与
plt.legend
类似,您将能够指定表的位置(锚定)。检查
plt.table
是否有kwarg调用
bbox\u to\u锚定
。如果是这样,那么就像使用
plt.legend
,您将能够指定表的位置(锚点)。这允许我移动它,但这些点的偏移量是多少?添加了到文档的链接。这允许我移动它,但这些点的偏移量是多少?添加了到文档的链接。