【问题标题】:Adding a table after a Python matplotlib basemap在 Python matplotlib 底图之后添加表格
【发布时间】:2016-10-17 09:45:08
【问题描述】:

我正在使用 matplotlib 底图创建地图,我想在其下方添加一个表格(例如 4 列,4 行),单元格中包含文本(文本和表格未以任何方式链接到底图)。我无法用子图做到这一点。这被保存为 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')

【问题讨论】:

    标签: python matplotlib matplotlib-basemap


    【解决方案1】:

    创建两个子图并将表格添加到第二个 ax 对象?请参阅Axes.table() 的文档

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

    table(**kwargs) 将表格添加到当前坐标区。

    调用签名:

    table(cellText=None, cellColours=None, cellLoc='right',colWidths=无, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None):返回一个 matplotlib.table.Table 实例。

    要对表格进行更细粒度的控制,请使用 Table 类 并使用 add_table() 将其添加到轴中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-05
      • 1970-01-01
      • 2023-03-22
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多