Skip to content

Commit e279275

Browse files
committed
Fix small rects in mathtext by expanding them to avoid snapping
1 parent 7217e2d commit e279275

19 files changed

Lines changed: 8 additions & 0 deletions

‎lib/matplotlib/backends/backend_agg.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
206206
gc1.set_linewidth(0)
207207
gc1.set_snap(gc.get_snap())
208208
for dx, dy, w, h in parse.rects: # dy is upwards & the rect top side.
209+
if gc1.get_snap() in [None, True]:
210+
# Prevent thin bars from disappearing by growing symmetrically.
211+
if w < 1:
212+
dx -= (1 - w) / 2
213+
w = 1
214+
if h < 1:
215+
dy -= (1 - h) / 2
216+
h = 1
209217
path = Path._create_closed(
210218
[(dx, dy), (dx + w, dy), (dx + w, dy + h), (dx, dy + h)])
211219
self._renderer.draw_path(
11 Bytes
Loading
6 Bytes
Loading
6 Bytes
Loading
13 Bytes
Loading
3 Bytes
Loading
-8 Bytes
Loading
16 Bytes
Loading
16 Bytes
Loading
16 Bytes
Loading

0 commit comments

Comments
 (0)