我正在使用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')
答案 0 :(得分:0)
创建两个子图并将表添加到第二个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 = None, rowLabels = None,rowColours = None,rowLoc ='left', colLabels = None,colColours = None,colLoc ='center', loc ='bottom',bbox = None):返回一个matplotlib.table.Table实例。
要对表进行更精细的控制,请使用Table类 并使用add_table()将其添加到轴中。