Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
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
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