【问题标题】:How can I increase the size of the table?如何增加表格的大小?
【发布时间】:2019-06-06 21:49:34
【问题描述】:

我正在尝试将 pandas 数据框显示为图像,但是当我使用 plt.show() 时,我得到了一张桌子的小图片,在一个大(不可见)子图中,占据了生成窗口的 90% .

我使用了这个代码:

    # ...

    ax = plt.subplot()

    ax.xaxis.set_visible(False)
    ax.yaxis.set_visible(False)

    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.spines['left'].set_visible(False)
    ax.spines['bottom'].set_visible(False)

    coeficientes_real_2 = coeficientes_real.transpose()

    table(ax, coeficientes_real_2, colWidths=[0.1, 0.1, 0.1], loc='center')

    plt.savefig('mytable.png')

    plt.show()

    #...

得到了这个结果:

如何增加表格的大小?

【问题讨论】:

    标签: python pandas matplotlib matplotlib-table


    【解决方案1】:

    基于this 的帖子,您可以使用缩放整个表格

    tb = table(ax, coeficientes_real_2, colWidths=[0.1, 0.1, 0.1], loc='center')
    tb.scale(2,2)
    

    或者单独更改列宽和字体大小:

    tb = table(ax, coeficientes_real_2, colWidths=2*[0.1, 0.1, 0.1], loc='center')
    tb.set_fontsize(24)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-23
      • 1970-01-01
      • 2012-11-07
      相关资源
      最近更新 更多