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

Skip to content

Commit 2d070d0

Browse files
committed
reduce cap_height in textstyle and pad top of fraction
1 parent 911cb37 commit 2d070d0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,8 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
27622762
if style is not self._MathStyle.DISPLAYSTYLE:
27632763
num.shrink()
27642764
den.shrink()
2765-
min_clearance = 0.5 * thickness
2765+
min_clearance = np.ceil(0.5 * thickness)
2766+
cap_height *= 0.7
27662767
else:
27672768
min_clearance = 1.5 * thickness
27682769
cnum = HCentered([num])
@@ -2771,18 +2772,20 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
27712772
cnum.hpack(width, 'exactly')
27722773
cden.hpack(width, 'exactly')
27732774

2774-
if cnum.height < cap_height:
2775-
cnum.height = cap_height
27762775
numerator_padding = max(
27772776
3/5 * cap_height - cnum.depth, min_clearance) - thickness
27782777
denominator_padding = max(
27792778
4/3 * cap_height - cden.height, min_clearance) + thickness
2780-
vlist = Vlist([cnum, # numerator
2781-
Vbox(0, numerator_padding), # space
2782-
Hrule(state, rule), # rule
2783-
Vbox(0, denominator_padding), # space
2784-
cden # denominator
2785-
])
2779+
vlist_builder = []
2780+
if cnum.height < cap_height:
2781+
vlist_builder.append(Vbox(0, cap_height - cnum.height))
2782+
vlist_builder += [cnum, # numerator
2783+
Vbox(0, numerator_padding), # space
2784+
Hrule(state, rule), # rule
2785+
Vbox(0, denominator_padding), # space
2786+
cden # denominator
2787+
]
2788+
vlist = Vlist(vlist_builder)
27862789

27872790
# Shift so the fraction line sits in the middle of the
27882791
# minus sign

0 commit comments

Comments
 (0)