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

Skip to content

Commit 4bfa0f9

Browse files
anntzerQuLogic
authored andcommitted
Fix positioning of mathtext Rules
At the call site https://github.com/matplotlib/matplotlib/blob/51fbfc4eb0e882ef7e95ceab9777c7047f4db819/lib/matplotlib/_mathtext.py#L1706-L1709 the box should clearly go from `cur_v + off_v` to `cur_v + off_v - rule_height` (this is why `cur_v` is shifted by `+ rule_height` just before; also at that point some print debugging indicates that y's go *downwards*), so `Rule.render` should indeed call `render_rect_filled` from `y - h` to `y`.
1 parent 94ff452 commit 4bfa0f9

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/matplotlib/_mathtext.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ def __init__(self, width: float, height: float, depth: float, state: ParserState
14531453

14541454
def render(self, output: Output, # type: ignore[override]
14551455
x: float, y: float, w: float, h: float) -> None:
1456-
self.fontset.render_rect_filled(output, x, y, w, h)
1456+
self.fontset.render_rect_filled(output, x, y - h, w, h)
14571457

14581458

14591459
class Hrule(Rule):
@@ -2699,12 +2699,11 @@ def _genfrac(self, ldelim: str, rdelim: str, rule: float | None, style: _MathSty
26992699
delta = rule / 2
27002700
num_clr = max((num_shift_up - cnum.depth) - (axis_height + delta), clr)
27012701
den_clr = max((axis_height - delta) - (cden.height - den_shift_down), clr)
2702-
# Possible bug in fraction rendering. See GitHub PR 22852 comments.
2703-
vlist = Vlist([cnum, # numerator
2704-
Vbox(0, num_clr - rule), # space
2705-
Hrule(state, rule), # rule
2706-
Vbox(0, den_clr + rule), # space
2707-
cden # denominator
2702+
vlist = Vlist([cnum, # numerator
2703+
Vbox(0, num_clr), # space
2704+
Hrule(state, rule), # rule
2705+
Vbox(0, den_clr), # space
2706+
cden # denominator
27082707
])
27092708
vlist.shift_amount = cden.height + den_clr + delta - axis_height
27102709

0 commit comments

Comments
 (0)