Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
For font features/languages, I ran into an issue in that theText
object is only supplied toRenderer.draw_text
if the string is not multiline:
matplotlib/lib/matplotlib/text.py
Line 805 inb4cb934
mtext=selfiflen(info)==1elseNone |
I tried a small change:
diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.pyindex 3b0de58814..b255a93c52 100644--- a/lib/matplotlib/text.py+++ b/lib/matplotlib/text.py@@ -800,9 +800,7 @@ class Text(Artist): angle = self.get_rotation() for line, wh, x, y in info:-- mtext = self if len(info) == 1 else None x = x + posx y = y + posy if renderer.flipy():@@ -816,14 +814,19 @@ class Text(Artist): else: textrenderer = renderer- if self.get_usetex():- textrenderer.draw_tex(gc, x, y, clean_line,- self._fontproperties, angle,- mtext=mtext)- else:- textrenderer.draw_text(gc, x, y, clean_line,- self._fontproperties, angle,- ismath=ismath, mtext=mtext)+ xt, yt = self.get_transform().inverted().transform((x, y))+ with cbook._setattr_cm(self, _x=xt, _y=yt, _text=clean_line,+ convert_xunits=lambda x: x,+ convert_yunits=lambda y: y,+ _horizontalalignment='left', _verticalalignment='bottom'):+ if self.get_usetex():+ textrenderer.draw_tex(gc, x, y, clean_line,+ self._fontproperties, angle,+ mtext=self)+ else:+ textrenderer.draw_text(gc, x, y, clean_line,+ self._fontproperties, angle,+ ismath=ismath, mtext=self) gc.restore() renderer.close_group('text')
AFAICT, only the PGF backend usesmtext
and under certain conditions will place the text using the original position and alignment instead of thex
/y
passed todraw_text
. Unfortunately, these don't seem to match (I assume the x/y passed in accounts for the descenders and other flourishes), so this breaks the PGF tests. I wonder if there's a better condition to be put in here:
matplotlib/lib/matplotlib/backends/backend_pgf.py
Lines 697 to 700 in6db18d5
ifmtextand ( | |
(angle==0or | |
mtext.get_rotation_mode()=="anchor")and | |
mtext.get_verticalalignment()!="center_baseline"): |
Originally posted by@QuLogic in#29695 (comment)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status