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

Skip to content

Commit 33cc440

Browse files
committed
BF: for degenerate polygons, add CLOSEPOLY vertex
1 parent ed4b877 commit 33cc440

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/patches.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,18 @@ def set_xy(self, xy):
10661066
----------
10671067
xy : (N, 2) array-like
10681068
The coordinates of the vertices.
1069+
1070+
Notes
1071+
-----
1072+
Unlike `~.path.Path`, we do not ignore the last input vertex. If the
1073+
polygon is meant to be closed, and the last point of the polygon is not
1074+
equal to the first, we assume that the user has not explicitly passed a
1075+
``CLOSEPOLY`` vertex, and add it ourselves.
10691076
"""
10701077
xy = np.asarray(xy)
1078+
N, _ = xy.shape
10711079
if self._closed:
1072-
if len(xy) and (xy[0] != xy[-1]).any():
1080+
if N == 1 or N > 1 and (xy[0] != xy[-1]).any():
10731081
xy = np.concatenate([xy, [xy[0]]])
10741082
else:
10751083
if len(xy) > 2 and (xy[0] == xy[-1]).all():

0 commit comments

Comments
 (0)