matplotlib作图添加表格

来源:互联网 发布:mac pr防抖 编辑:程序博客网 时间:2024/05/22 12:20
import matplotlib.pyplot as pltimport numpy as npplt.figure()ax = plt.gca()y = np.random.randn(9)col_labels = ['col1','col2','col3']row_labels = ['row1','row2','row3']table_vals = [[11,12,13],[21,22,23],[28,29,30]]row_colors = ['red','gold','green']my_table = plt.table(cellText=table_vals, colWidths=[0.1]*3,                     rowLabels=row_labels, colLabels=col_labels,                     rowColours=row_colors, colColours=row_colors,                     loc='best')plt.plot(y)plt.show()

这里写图片描述