Skip to content

Commit 950d0db

Browse files
authored
Merge pull request matplotlib#25784 from QuLogic/ps-usetex-anchor
ps: Fix anchoring of rotated usetex text
2 parents ccad5ef + b11ea41 commit 950d0db

File tree

6 files changed

+10850
-2
lines changed

6 files changed

+10850
-2
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
588588
s = fontcmd % s
589589
tex = r'\color[rgb]{%s} %s' % (color, s)
590590

591-
# Stick to the bottom alignment.
592-
pos = _nums_to_str(x, y-bl)
591+
# Stick to bottom-left alignment, so subtract descent from the text-normal
592+
# direction since text is normally positioned by its baseline.
593+
rangle = np.radians(angle + 90)
594+
pos = _nums_to_str(x - bl * np.cos(rangle), y - bl * np.sin(rangle))
593595
self.psfrag.append(
594596
r'\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}' % (
595597
thetext, angle, fontsize, fontsize*1.25, tex))

0 commit comments

Comments
 (0)