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

Skip to content

[Bug]: bbox computed incorrectly when using a superscript #21653

Open
@kc9jud

Description

@kc9jud

Bug summary

When including LaTeX with a superscript, the bbox is computed incorrectly.

Code for reproduction

import matplotlib.pyplot as plt

kw = dict(
    usetex=True,
    fontsize=40,
    bbox=dict(boxstyle='round,pad=0', fc='lightsteelblue', ec='none')
)

plt.axhline(y=0.7)
plt.annotate('A', xy=(0.3, 0.7), **kw)
plt.annotate(r'$A$', xy=(0.4, 0.7), **kw)
plt.annotate(r'$^{\tiny 1}A$', xy=(0.5, 0.7), **kw)
plt.annotate(r'$^{\tiny 1j}A$', xy=(0.65, 0.7), **kw)

plt.axhline(y=0.4)
plt.annotate('A', xy=(0.3, 0.4), va='bottom', **kw)
plt.annotate(r'$A$', xy=(0.4, 0.4), va='bottom', **kw)
plt.annotate(r'$^{1}A$', xy=(0.5, 0.4), va='bottom', **kw)
plt.annotate(r'$^{1j}A$', xy=(0.65, 0.4), va='bottom', **kw)

plt.show()

Actual outcome

Figure_1

Expected outcome

The bounding box should correctly surround the superscript.

Additional information

Related bugs: #7075 #14177

Operating system

Ubuntu

Matplotlib Version

3.5.0

Matplotlib Backend

No response

Python version

3.8.10

Jupyter version

No response

Installation

pip

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