在 Python matplotlib 底图后添加 table

Adding a table after a Python matplotlib basemap

我正在使用 matplotlib 底图创建地图,我想在其下方添加一个 table(比如 4 列,4 行),并在单元格中添加文本(文本和 table 不是以任何方式链接到底图)。我无法对子图这样做。这被保存为 1 页 pdf。有什么建议吗?

from mpl_toolkits.basemap import Basemap
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(11.69*2, 8.27*2), dpi=120)
fig.add_axes([0.1,0.1,0.8,0.8])
map = Basemap(projection='merc', lat_0=57, lon_0=-135, resolution = 'l', area_thresh = 10000, llcrnrlon=-110, llcrnrlat=-50, urcrnrlon=150, urcrnrlat=60)
# A lot of map calls drawing the map
plt.savefig('map.pdf', bbox_inches='tight')

创建两个子图并向第二个斧头对象添加一个table?请参阅 Axes.table()

的文档

http://matplotlib.org/api/axes_api.html?highlight=table#matplotlib.axes.Axes.table

table(**kwargs) Add a table to the current axes.

Call signature:

table(cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None): Returns a matplotlib.table.Table instance.

For finer grained control over tables, use the Table class and add it to the axes with add_table().