1

I'm trying to display a pandas dataframe as an image, but when I use plt.show(), I got a small picture of the table, inside a big (invisible) subplot, occupying 90% of the generated window.

I used this code:

    # ...

    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()

    #...

And got this result:

Result

How can I increase the size of the table?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Enzo Dtz
  • 361
  • 1
  • 16

1 Answers1

3

Based on this post, you can scale the whole table with

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

Or change the column width and font size individually:

tb = table(ax, coeficientes_real_2, colWidths=2*[0.1, 0.1, 0.1], loc='center')
tb.set_fontsize(24)
Sheldore
  • 37,862
  • 7
  • 57
  • 71