Skip to content

[Bug]: fontsize in tables not working #29202

@acgc99

Description

@acgc99

Bug summary

Specifying fontsize kwarg in matplotlib.pyplot.table doesn't have any effect.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = x + 1
tableData = [['a', 1], ['b', 1]]

fig, ax = plt.subplots()
ax.plot(x, y)
t = ax.table(
    cellText=tableData,
    loc='top',
    cellLoc='center',
    fontsize=30
)
plt.show()

Actual outcome

Figure_1

Expected outcome

A table with bigger font size.

Additional information

This works:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = x + 1
tableData = [['a', 1], ['b', 1]]

fig, ax = plt.subplots()
ax.plot(x, y)
t = ax.table(
    cellText=tableData,
    loc='top',
    cellLoc='center'
)
t.set_fontsize(30)  # <----------------
plt.show()

Figure_1

Operating system

Windows 11

Matplotlib Version

3.8.2

Matplotlib Backend

QtAgg

Python version

3.12.0

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!topic: table

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions