Python Forum

Full Version: How to change the font size of a table?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm fighting for hours to change the size of the numbers which fills the cells of a table created with matplotlib. Here's my code for a subplot table:
rows = ['%d' % i for i in np.arange(1,prism+1)]
columns = ('Mt (A)','inc ($^\circ$)','x0 (m)','z0 (m)')
   
prec = np.asarray(data_prec)

cell_text = []
for row in range(prism):
   cell_text.append(['%.1f $\pm$ %.1f' % item for item in zip(p[row,0:4],prec[row,0:4])])
ax6=plt.subplot2grid((3,3), (2,2), colspan=1, frameon=False)
ax6.table(cellText=cell_text,rowLabels=rows,colLabels=columns,loc='center')
ax6.get_xaxis().set_visible(False)
ax6.get_yaxis().set_visible(False)
ax6.set_title('f)', fontsize=12, fontweight="bold", position=(-0.05,0.85))

plt.show()
I also tried to use fontsize on line 10 of the code, but without success. At this moment the code creates a table using the arrays "p" and "prec". Everything is ok, except by the fact of the table font has size like 6 or 8, too small for my necessity.

If anyone could show me how to change the font size, it would be super helpful.