Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: bbox and alignment issues with math text #22459

Open
@gartrog

Description

@gartrog

Bug summary

There are several issues with bbox and text alignement when math is used, as evidenced in the mwe below.

In the 'normal' case (1st line), all is ok.

When using mathtext (2nd), the height of the bounding box depends on the text contents while it should not (no fancy super/under script that would extend beyond 'lp'). Also note that the horizontal alignment is different wrt the 1st and 3rd lines (space to the left of the V, no space to the right of the last letter).

When using 'usetex' (3rd line), the bounding box seems correctly placed, but the text position itself in the second case is off by a little bit (see the 'l' being slightly above the line).

Code for reproduction

importmatplotlib.pyplotaspltkw=dict(fontsize=55,bbox=dict(boxstyle='round,pad=0',fc='lightsteelblue',ec='none'))plt.annotate('V lp',xy=(0.2,0.7),**kw)plt.annotate('V l',xy=(0.5,0.7),**kw)plt.axhline(y=0.7,zorder=10)plt.annotate('$V$ lp',xy=(0.2,0.4),**kw)plt.annotate('$V$ l',xy=(0.5,0.4),**kw)plt.axhline(y=0.4,zorder=10)plt.annotate('$V$ lp',xy=(0.2,0.1),usetex=True,**kw)plt.annotate('$V$ l',xy=(0.5,0.1),usetex=True,**kw)plt.axhline(y=0.1,zorder=10)plt.show()

Actual outcome

example

Expected outcome

2nd row: the height of the first bbox should be fixed.

3rd row: the vertical positioning of the text in the second case should be fixed.

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

QtAgg

Python version

3.10.2

Jupyter version

No response

Installation

No response

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp