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

Skip to content

Commit 6598fad

Browse files
author
James Evans
committed
Fixed a divide by zero error that happens if there is no space for both an arrow
and a line.
1 parent 7900ee4 commit 6598fad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/patches.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,9 @@ 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+
hasBeginArrow = self.beginArrow and not ((x0==x1) and (y0==y1))
3313+
if hasBeginArrow:
33123314
verticesA, codesA, ddxA, ddyA = \
33133315
self._get_arrow_wedge(x1, y1, x0, y0,
33143316
head_dist, cos_t, sin_t,
@@ -3321,7 +3323,9 @@ def transmute(self, path, mutation_size, linewidth):
33213323
x2, y2 = path.vertices[-2]
33223324
x3, y3 = path.vertices[-1]
33233325

3324-
if self.endarrow:
3326+
# If there is no room for an arrow and a line, then skip the arrow
3327+
hasEndArrow = self.endArrow and not ((x2==x3) and (y2==y3))
3328+
if hasEndArrow:
33253329
verticesB, codesB, ddxB, ddyB = \
33263330
self._get_arrow_wedge(x2, y2, x3, y3,
33273331
head_dist, cos_t, sin_t,
@@ -3338,7 +3342,7 @@ def transmute(self, path, mutation_size, linewidth):
33383342
path.codes)]
33393343
_fillable = [False]
33403344

3341-
if self.beginarrow:
3345+
if hasBeginArrow:
33423346
if self.fillbegin:
33433347
p = np.concatenate([verticesA, [verticesA[0],
33443348
verticesA[0]], ])
@@ -3349,7 +3353,7 @@ def transmute(self, path, mutation_size, linewidth):
33493353
_path.append(Path(verticesA, codesA))
33503354
_fillable.append(False)
33513355

3352-
if self.endarrow:
3356+
if hasEndArrow:
33533357
if self.fillend:
33543358
_fillable.append(True)
33553359
p = np.concatenate([verticesB, [verticesB[0],

0 commit comments

Comments
 (0)