【发布时间】:2017-06-09 18:46:20
【问题描述】:
在 matplotlib 2.0 中,当我在同一个字符上同时使用下标和上标时,我的行为一直很奇怪。当它们组合在一起时,下标完全低于基线。 MPL 1.5 没有发生这种情况。这是一个完整的例子:
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rc("font", family="Times New Roman",weight='normal')
plt.rcParams.update({'mathtext.default': 'regular' })
plt.plot(1,1, label='$A_x^{b}$')
plt.plot(2,2,label='$A_x$')
plt.plot(3,3,label='$A^b$')
plt.plot(4,4,label='$A_x^{*}$')
plt.plot(5,5,label='$A^*$')
plt.legend(fontsize='xx-large')
plt.show()
我拍摄了这张图并放大了图例并绘制了一些水平线以显示相对的上标和下标位置。
我在 mathtext.py 文件中的 FontConstantBase 类下找到了这些参数:
# Percentage of x-height of additional horiz. space after sub/superscripts
script_space = 0.05
# Percentage of x-height that sub/superscripts drop below the baseline
subdrop = 0.4
# Percentage of x-height that superscripts are raised from the baseline
sup1 = 0.7
# Percentage of x-height that subscripts drop below the baseline
sub1 = 0.3
# Percentage of x-height that subscripts drop below the baseline when a
# superscript is present
sub2 = 0.5
# Percentage of x-height that sub/supercripts are offset relative to the
# nucleus edge for non-slanted nuclei
delta = 0.025
# Additional percentage of last character height above 2/3 of the
# x-height that supercripts are offset relative to the subscript
# for slanted nuclei
delta_slanted = 0.2
# Percentage of x-height that supercripts and subscripts are offset for
# integrals
delta_integral = 0.1
sub2 在以前的版本中存在吗?像我看到的那样,从 0.3 到 0.5 真的可以完全降到基线以下吗?我希望同时拥有不完全超出基线的上标和下标,除了修改 mathtext.py 本身之外,我看不到任何其他方式。此外,似乎在上标中包含星号时,它也高于 mpl 2.0 的预期。有没有办法在不改变数学文本的情况下稍微降低它?谢谢。
【问题讨论】:
-
你能为此创建一个 github 问题吗? (如果尚不存在)
标签: python matplotlib subscript