markusian markusian - 1 month ago 13
Python Question

Centered text in matplotlib tables

I am trying to center the text inside a matplotlib table cell, while the default seems to be right aligned. I looked through the documentation of the Table object, but I could not find anything useful in this.

Is there an easy way to achieve the centering?

Answer

Try editing the sample here

Adding

cellLoc='center'

To

the_table = plt.table(cellText=cell_text, rowLabels=rows, rowColours=colors, colLabels=columns, loc='bottom')

To get enter image description here