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

Skip to content

Commit 19c5d01

Browse files
committed
Merge pull request #4919 from tacaswell/issue08
FIX: fix divide by zero in short arrows
2 parents 0e3a6ae + b89a2ef commit 19c5d01

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/matplotlib/patches.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,10 @@ def transmute(self, path, mutation_size, linewidth):
33083308
x0, y0 = path.vertices[0]
33093309
x1, y1 = path.vertices[1]
33103310

3311-
if self.beginarrow:
3311+
# If there is no room for an arrow and a line, then skip the arrow
3312+
has_begin_arrow = (self.beginarrow and
3313+
not ((x0 == x1) and (y0 == y1)))
3314+
if has_begin_arrow:
33123315
verticesA, codesA, ddxA, ddyA = \
33133316
self._get_arrow_wedge(x1, y1, x0, y0,
33143317
head_dist, cos_t, sin_t,
@@ -3321,7 +3324,9 @@ def transmute(self, path, mutation_size, linewidth):
33213324
x2, y2 = path.vertices[-2]
33223325
x3, y3 = path.vertices[-1]
33233326

3324-
if self.endarrow:
3327+
# If there is no room for an arrow and a line, then skip the arrow
3328+
has_end_arrow = (self.endarrow and not ((x2 == x3) and (y2 == y3)))
3329+
if has_end_arrow:
33253330
verticesB, codesB, ddxB, ddyB = \
33263331
self._get_arrow_wedge(x2, y2, x3, y3,
33273332
head_dist, cos_t, sin_t,
@@ -3338,7 +3343,7 @@ def transmute(self, path, mutation_size, linewidth):
33383343
path.codes)]
33393344
_fillable = [False]
33403345

3341-
if self.beginarrow:
3346+
if has_begin_arrow:
33423347
if self.fillbegin:
33433348
p = np.concatenate([verticesA, [verticesA[0],
33443349
verticesA[0]], ])
@@ -3349,7 +3354,7 @@ def transmute(self, path, mutation_size, linewidth):
33493354
_path.append(Path(verticesA, codesA))
33503355
_fillable.append(False)
33513356

3352-
if self.endarrow:
3357+
if has_end_arrow:
33533358
if self.fillend:
33543359
_fillable.append(True)
33553360
p = np.concatenate([verticesB, [verticesB[0],

0 commit comments

Comments
 (0)