#32316·matplotlib

[Bug]: misaligned between xticklabel baselines

Author: anntzerCreated Sep 8, 2026Updated Sep 18, 2026
Labelstopic: text

Bug summary

Custom xticklabels can have their baselines misaligned.

Code for reproduction

python
from pylab import *

mpl.rcdefaults()
mpl.rcParams.update({"font.size": 9})

figure(figsize=(.5, .5), layout="constrained")
# push the xticks next to one another to make things more visible
yticks([]); xlim(-2, 3); xticks([0, 1])
gca().xaxis.set_major_formatter(lambda x, i: "pol." if x == 0 else str(int(x)))
show()

Actual outcome

Image

Note the baseline misalignment between "pol." and "1".

Expected outcome

No misalignment.

Additional information

Although this may seem similar to #31802, this is a regression in 3.11 (present both in agg and in mplcairo) -- I don't know if something else broke a previously accidentally correct alignment, and didn't run a full bisection. Maybe related to #31107.

Operating system

macos

Matplotlib Version

matplotlib-3.12.0.dev427+g4f7461066; bisected against 3.10.9

Matplotlib Backend

agg or mplcairo

Python version

3.14

Jupyter version

No response

Installation

git checkout