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

Skip to content

Commit 96f87f9

Browse files
committed
Merge pull request #3017 from pwuertz/fix_3000
Do not provide (wrong) mtext instances for pre-layouted text blocks (fixes #3000)
2 parents 9564d80 + 75129c9 commit 96f87f9

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2014-05-16 Fixed the positioning of multi-line text in the PGF backend.
2+
13
2014-05-14 Added Axes.add_image() as the standard way to add AxesImage
24
instances to Axes. This improves the consistency with
35
add_artist(), add_collection(), add_container(), add_line(),

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
651651

652652
f = 1.0 / self.figure.dpi
653653
text_args = []
654-
if angle == 0 or mtext.get_rotation_mode() == "anchor":
654+
if mtext and (angle == 0 or mtext.get_rotation_mode() == "anchor"):
655655
# if text anchoring can be supported, get the original coordinates
656656
# and add alignment information
657657
x, y = mtext.get_transform().transform_point(mtext.get_position())

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10051005
style['font-style'] = prop.get_style().lower()
10061006
attrib['style'] = generate_css(style)
10071007

1008-
if angle == 0 or mtext.get_rotation_mode() == "anchor":
1008+
if mtext and (angle == 0 or mtext.get_rotation_mode() == "anchor"):
10091009
# If text anchoring can be supported, get the original
10101010
# coordinates and add alignment information.
10111011

lib/matplotlib/text.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ def draw(self, renderer):
564564
if not np.isfinite(x) or not np.isfinite(y):
565565
continue
566566

567+
mtext = self if len(info) == 1 else None
567568
x = x + posx
568569
y = y + posy
569570
if renderer.flipy():
@@ -577,11 +578,11 @@ def draw(self, renderer):
577578

578579
if rcParams['text.usetex']:
579580
renderer.draw_tex(gc, x, y, clean_line,
580-
self._fontproperties, angle, mtext=self)
581+
self._fontproperties, angle, mtext=mtext)
581582
else:
582583
renderer.draw_text(gc, x, y, clean_line,
583584
self._fontproperties, angle,
584-
ismath=ismath, mtext=self)
585+
ismath=ismath, mtext=mtext)
585586

586587
gc.restore()
587588
renderer.close_group('text')

0 commit comments

Comments
 (0)