@@ -687,7 +687,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
687687 writeln (self .fh , r"\pgfsetfillcolor{textcolor}" )
688688 s = r"\color{textcolor}" + s
689689
690- f = 1.0 / self .figure .dpi
690+ dpi = self .figure .dpi
691691 text_args = []
692692 if mtext and (
693693 (angle == 0 or
@@ -697,20 +697,18 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
697697 # and add alignment information
698698 pos = mtext .get_unitless_position ()
699699 x , y = mtext .get_transform ().transform (pos )
700- text_args .append ("x=%fin" % (x * f ))
701- text_args .append ("y=%fin" % (y * f ))
702-
703700 halign = {"left" : "left" , "right" : "right" , "center" : "" }
704701 valign = {"top" : "top" , "bottom" : "bottom" ,
705702 "baseline" : "base" , "center" : "" }
706- text_args .append (halign [mtext .get_horizontalalignment ()])
707- text_args .append (valign [mtext .get_verticalalignment ()])
703+ text_args .extend ([
704+ f"x={ x / dpi } in" ,
705+ f"y={ y / dpi } in" ,
706+ halign [mtext .get_horizontalalignment ()],
707+ valign [mtext .get_verticalalignment ()],
708+ ])
708709 else :
709- # if not, use the text layout provided by matplotlib
710- text_args .append ("x=%fin" % (x * f ))
711- text_args .append ("y=%fin" % (y * f ))
712- text_args .append ("left" )
713- text_args .append ("base" )
710+ # if not, use the text layout provided by Matplotlib.
711+ text_args .append (f"x={ x / dpi } in, y={ y / dpi } in, left, base" )
714712
715713 if angle != 0 :
716714 text_args .append ("rotate=%f" % angle )
0 commit comments