Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: misaligned between xticklabel baselines #32316

Description

@anntzer

Bug summary

Custom xticklabels can have their baselines misaligned.

Code for reproduction

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions