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

Skip to content

Commit cc08a02

Browse files
committed
Make an empty path_effect path for an empty string
1 parent b3ef54f commit cc08a02

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/matplotlib/patheffects.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ def draw_path_collection(self, gc, master_transform, paths, *args,
138138
*args, **kwargs)
139139

140140
def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
141-
if not s.strip():
142-
return
143-
144141
# Implements the naive text drawing as is found in RendererBase.
145142
path, transform = self._get_text_path_transform(x, y, s, prop,
146143
angle, ismath)

lib/matplotlib/textpath.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ def get_text_path(self, prop, s, ismath=False):
129129
verts.extend(verts1)
130130
codes.extend(codes1)
131131

132+
# Make sure an empty string or one with nothing to print
133+
# (e.g. only spaces & newlines) will be valid/empty path
134+
if not verts:
135+
verts = np.empty((0, 2))
136+
132137
return verts, codes
133138

134139
def get_glyphs_with_font(self, font, s, glyph_map=None,

0 commit comments

Comments
 (0)