Skip to content

Commit 6dd8aac

Browse files
committed
Merge pull request #559 from mdboom/arrow_bug
arrow_bug
2 parents 453138f + fbf419b commit 6dd8aac

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lib/matplotlib/patches.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def set_closed(self, closed):
790790
def get_xy(self):
791791
return self._path.vertices
792792
def set_xy(self, vertices):
793-
self._path = Path(vertices)
793+
self._path = Path(vertices, closed=self._closed)
794794
_get_xy = get_xy
795795
_set_xy = set_xy
796796
xy = property(
@@ -871,7 +871,8 @@ def __str__(self):
871871
[ 0.0, 0.1 ], [ 0.0, -0.1],
872872
[ 0.8, -0.1 ], [ 0.8, -0.3],
873873
[ 1.0, 0.0 ], [ 0.8, 0.3],
874-
[ 0.8, 0.1 ], [ 0.0, 0.1] ] )
874+
[ 0.8, 0.1 ], [ 0.0, 0.1] ],
875+
closed=True)
875876

876877
@docstring.dedent_interpd
877878
def __init__( self, x, y, dx, dy, width=1.0, **kwargs ):
@@ -979,7 +980,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, \
979980
M = np.array([[cx, sx],[-sx,cx]])
980981
verts = np.dot(coords, M) + (x+dx, y+dy)
981982

982-
Polygon.__init__(self, map(tuple, verts), **kwargs)
983+
Polygon.__init__(self, map(tuple, verts), closed=True, **kwargs)
983984

984985
docstring.interpd.update({"FancyArrow":FancyArrow.__init__.__doc__})
985986

@@ -1051,7 +1052,7 @@ def get_path(self):
10511052
xs = self.convert_xunits([xb1, xb2, xc2, xd2, x1, xd1, xc1, xb1])
10521053
ys = self.convert_yunits([yb1, yb2, yc2, yd2, y1, yd1, yc1, yb1])
10531054

1054-
return Path(zip(xs, ys))
1055+
return Path(zip(xs, ys), closed=True)
10551056

10561057
def get_patch_transform(self):
10571058
return transforms.IdentityTransform()
@@ -3696,18 +3697,18 @@ def set_dpi_cor(self, dpi_cor):
36963697
dpi_cor is currently used for linewidth-related things and
36973698
shink factor. Mutation scale is not affected by this.
36983699
"""
3699-
3700+
37003701
self._dpi_cor = dpi_cor
37013702

37023703
def get_dpi_cor(self):
37033704
"""
37043705
dpi_cor is currently used for linewidth-related things and
37053706
shink factor. Mutation scale is not affected by this.
37063707
"""
3707-
3708+
37083709
return self._dpi_cor
37093710

3710-
3711+
37113712
def set_positions(self, posA, posB):
37123713
""" set the begin end end positions of the connecting
37133714
path. Use current vlaue if None.
@@ -3905,7 +3906,7 @@ def draw(self, renderer):
39053906

39063907
# FIXME : dpi_cor is for the dpi-dependecy of the
39073908
# linewidth. There could be room for improvement.
3908-
#
3909+
#
39093910
#dpi_cor = renderer.points_to_pixels(1.)
39103911
self.set_dpi_cor(renderer.points_to_pixels(1.))
39113912
path, fillable = self.get_path_in_displaycoord()
@@ -4167,7 +4168,7 @@ def get_path_in_displaycoord(self):
41674168
"""
41684169

41694170
dpi_cor = self.get_dpi_cor()
4170-
4171+
41714172
x, y = self.xy1
41724173
posA = self._get_xy(x, y, self.coords1, self.axesA)
41734174

lib/matplotlib/path.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Path(object):
8080

8181
code_type = np.uint8
8282

83-
def __init__(self, vertices, codes=None, _interpolation_steps=1):
83+
def __init__(self, vertices, codes=None, _interpolation_steps=1, closed=False):
8484
"""
8585
Create a new path with the given vertices and codes.
8686
@@ -117,6 +117,11 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1):
117117
assert len(codes) == len(vertices)
118118
if len(codes):
119119
assert codes[0] == self.MOVETO
120+
elif closed:
121+
codes = np.empty(len(vertices)) * 2
122+
codes[0] = self.MOVETO
123+
codes[1:-1] = self.LINETO
124+
codes[-1] = self.CLOSEPOLY
120125

121126
assert vertices.ndim == 2
122127
assert vertices.shape[1] == 2

0 commit comments

Comments
 (0)