您需要获取单元格的文本字体属性:
import matplotlib.pyplot as plt
table=plt.table(cellText=[' ', ' ', ' ', ' ', ' '], #rows of data values
rowLabels=['1','2','3','4','5'],
cellLoc="left",
rowLoc='left',
bbox=[0,0,.2,1],#[left,bottom,width,height]
edges="")
# iterate through cells of a table
table_props = table.properties()
table_cells = table_props['child_artists']
for cell in table_cells:
cell.get_text().set_fontsize(20)
cell.get_text().set_color('grey')
plt.show()
获取单元格文本属性的另一种方法是使用单元格索引(i,j):
table[(i, j)].get_text().set_fontsize(12)
table[(i, j)].get_text().set_color('red')
Matplotlib文本字体属性在此处进行了描述:http ://matplotlib.org/api/text_api.html#matplotlib.text.Text.set_fontproperties
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句