-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
a bug that latex expression with subscripts exceeds bbox #14177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Example
Observations
|
@timhoffm's example now gives |
My (non-verified) guess is that the 1px shift is related to the "wiggly baseline" mentioned in #5414, which basically arises because mathtext/usetex texts (which are basically prerendered as bitmaps first) use their top-right corner as reference point, but there's some rounding associated with it if the text object gets antialiased past the top limit, which (handwavingly) leads to the baseline wiggling; instead, these bitmaps should use the baseline as reference y to avoid the problem. |
This still seems to be a problem with more complex situations: 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 \n B', xy=(0.4, 0.7), **kw)
plt.annotate(r'$A$' ' \n ' r'$B$', xy=(0.5, 0.7), **kw)
plt.annotate(r'$A_{\tiny 1}$' ' \n ' r'$B_{\tiny 1}$', xy=(0.6, 0.7), **kw)
plt.annotate(r'$A_{\tiny 1j}$' ' \n ' r'$A_{\tiny 1j}$', xy=(0.8, 0.7), **kw)
plt.axhline(y=0.3)
plt.annotate('A \n B', xy=(0.4, 0.3), va='bottom', **kw)
plt.annotate(r'$A$' ' \n ' r'$B$', xy=(0.5, 0.3), va='bottom', **kw)
plt.annotate(r'$A_{1}$' ' \n ' r'$B_{\tiny 1}$', xy=(0.6, 0.3), va='bottom', **kw)
plt.annotate(r'$A_{1j}$' ' \n ' r'$A_{\tiny 1j}$', xy=(0.8, 0.3), va='bottom', **kw)
plt.annotate(r'$^6\mathrm{He}$ $0^+$' ' \n ' r'$n0p_{3/2}$', xy=(0.05, 0.3), va='bottom', **kw)
plt.show() |
This looks to be an issue with superscripts -- I will open a new issue. |
Your example is helpful. Maybe add to #7075 which I think is the same thing (if more convoluted) |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Haven't checked but almost likely still valid as no work has been done on these aspects, and will likely be stalled until the image comparison framework is fixed as any change to the wiggly baselines will involve regen'ing many, many reference images (#21653 (comment))? |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
the background box for a text object that is composed via latex with subscript can not be covered by the box if letting the padding of the box be equal to 0
Expected outcome : the text has a white background as small as possible and include all of the text
Actual outcome : the text always exceeds the bbox unless using a bigger padding that is ugly
Matplotlib version
print(matplotlib.get_backend())
): tkaggThe text was updated successfully, but these errors were encountered: