user13412850
user13412850

Reputation: 519

How do I change the font size of the data in the table in Matplotlib?

I have taken one of the solutions from this page How do I plot only a table in Matplotlib?

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

# hide axes
fig.patch.set_visible(False)
ax.axis('off')
ax.axis('tight')

df = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD'))

ax.table(cellText=df.values, colLabels=df.columns, loc='center')

fig.tight_layout()

plt.show()

adding this didn't make any difference to the font size

ax.table(cellText=df.values, colLabels=df.columns, loc='center',fontsize=14)

how else can I change the size?

Upvotes: 0

Views: 733

Answers (1)

skowalak
skowalak

Reputation: 459

Just add this line before plt.show:

plt.rcParams.update({'font.size': 14})

Upvotes: 1

Related Questions