From bc870662830b7dcbfab9a2439914b0ef89e0705d Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 12 Nov 2017 17:59:14 -0800 Subject: [PATCH] FIX: better handling of multi-line text objects in draw --- lib/matplotlib/text.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index a55afdb49b69..62e70fcb0495 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -722,7 +722,9 @@ def draw(self, renderer): # position in Text, and dash position in TextWithDash: posx = float(textobj.convert_xunits(textobj._x)) posy = float(textobj.convert_yunits(textobj._y)) + _log.debug('posx %1.1f, posy %1.1f', posx, posy) posx, posy = trans.transform_point((posx, posy)) + _log.debug('trans posx %1.1f, posy %1.1f', posx, posy) if not np.isfinite(posx) or not np.isfinite(posy): _log.warning("posx and posy should be finite values") return @@ -741,10 +743,17 @@ def draw(self, renderer): angle = textobj.get_rotation() for line, wh, x, y in info: - - mtext = textobj if len(info) == 1 else None x = x + posx y = y + posy + # note that y is the bottom of the text... + if len(info) > 1: + _log.debug('info > 1') + x_, y_ = trans.inverted().transform_point((x, y)) + mtext = Text(text=line, x=textobj._x, y=y_) + mtext.update_from(textobj) + mtext._verticalalignment = 'bottom' + else: + mtext = textobj if renderer.flipy(): y = canvash - y clean_line, ismath = textobj.is_math_text(line,