【问题标题】:Changing fontsize for Matplotlib table? [duplicate]更改 Matplotlib 表的字体大小? [复制]
【发布时间】:2019-05-20 16:37:27
【问题描述】:

我使用 matplotlib 的表格功能从数据框创建了一个表格。但是,即使我更改了字体大小,字体看起来还是一样,我不确定为什么。我什至还尝试扩大或缩小 figsize,但这没有任何作用。如何更改单元格文本大小?谢谢!

fig = plt.figure(figsize=(5,3))
ax = plt.subplot(111)
ax.axis('off')
ax.table(cellText=df.values, colLabels=df.columns, bbox=[0,0,1,1], fontsize = 12)

【问题讨论】:

  • 查看这个link它会回答你的问题

标签: python pandas dataframe matplotlib font-size


【解决方案1】:

使用set_fontsize():

fig = plt.figure(figsize=(5,3))
ax = plt.subplot(111)
ax.axis('off')
tab = ax.table(cellText=df.values, colLabels=df.columns, bbox=[0,0,1,1])
tab.set_fontsize(14)

请参阅doc 以获取更多说明。

【讨论】:

    猜你喜欢
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 2018-01-24
    • 2015-08-23
    • 1970-01-01
    相关资源
    最近更新 更多