Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: better handling of multi-line text objects in draw #9775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down