当前位置:   article > 正文

用python的画表格_python plottable columndefinition camp

python plottable columndefinition camp

%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
randn = np.random.randn
from pandas import *
idx = Index(np.arange(1,7))
df = DataFrame(randn(6, 4), index=idx, columns=['A', 'B', 'C', 'D'])
vals = np.around(df.values,2)
fig = plt.figure(figsize=(9,4))
ax = fig.add_subplot(111, frameon=True, xticks=[], yticks=[])
the_table=plt.table(cellText=vals, rowLabels=df.index, colLabels=df.columns, 
                    colWidths = [0.1]*vals.shape[1], loc='center',cellLoc='center')
the_table.set_fontsize(20)

the_table.scale(2.5,2.58)

使用matplot表值画图的图例调整为表格

 

缺点是:不能像数据框一样对齐

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/993066
推荐阅读
相关标签
  

闽ICP备14008679号