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

Skip to content

Commit e2f8591

Browse files
committed
Fix draw_text methods for handling mtext=None.
1 parent 9564d80 commit e2f8591

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

0 commit comments

Comments
 (0)