Another answer which edits the cell's alignment individually, serves this case and a more general one where only arbitrary columns (but not all) are to be centered (or any specific cells to that case).
Let's say you have a 5 rows - 3 columns table. If you want to edit only first column:
the_table = plt.table(cellText=cell_text,
rowLabels=rows,
rowColours=colors,
colLabels=columns,
loc='bottom')
cells = the_table.properties()["celld"]
for i in range(0, 5):
cells[i, 0]._loc = 'center'
I was stuck with this until I took a look at table.py
source
EDIT 10/24/2021: As of today the above approach doesn't seem to work. It is however easy to fix it using set_text_props
method of Cell objects (don't know if it didn't exit back then or I was unaware of it). To test it just add the following lines before the plt.show()
of the official table demo. In this case the 4th column is centered.
cells = the_table.properties()["celld"]
for i in range(0, 5):
cells[i, 3].set_text_props(ha="center")