MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_xy

Method set_xy

lib/matplotlib/patches.py:1295–1326  ·  view source on GitHub ↗

Set the vertices of the polygon. Parameters ---------- xy : (N, 2) array-like The coordinates of the vertices. Notes ----- Unlike `.Path`, we do not ignore the last input vertex. If the polygon is meant to be closed, and

(self, xy)

Source from the content-addressed store, hash-verified

1293 return self._path.vertices
1294
1295 def set_xy(self, xy):
1296 """
1297 Set the vertices of the polygon.
1298
1299 Parameters
1300 ----------
1301 xy : (N, 2) array-like
1302 The coordinates of the vertices.
1303
1304 Notes
1305 -----
1306 Unlike `.Path`, we do not ignore the last input vertex. If the
1307 polygon is meant to be closed, and the last point of the polygon is not
1308 equal to the first, we assume that the user has not explicitly passed a
1309 ``CLOSEPOLY`` vertex, and add it ourselves.
1310 """
1311 xy = np.asarray(xy)
1312 nverts, _ = xy.shape
1313 if self._closed:
1314 # if the first and last vertex are the "same", then we assume that
1315 # the user explicitly passed the CLOSEPOLY vertex. Otherwise, we
1316 # have to append one since the last vertex will be "ignored" by
1317 # Path
1318 if nverts == 1 or nverts > 1 and (xy[0] != xy[-1]).any():
1319 xy = np.concatenate([xy, [xy[0]]])
1320 else:
1321 # if we aren't closed, and the last vertex matches the first, then
1322 # we assume we have an unnecessary CLOSEPOLY vertex and remove it
1323 if nverts > 2 and (xy[0] == xy[-1]).all():
1324 xy = xy[:-1]
1325 self._path = Path(xy, closed=self._closed)
1326 self.stale = True
1327
1328 xy = property(get_xy, set_xy,
1329 doc='The vertices of the path as a (N, 2) array.')

Callers 5

__init__Method · 0.95
set_closedMethod · 0.95
test_Polygon_closeFunction · 0.95
set_dataMethod · 0.45
update_polygonFunction · 0.45

Calls 1

PathClass · 0.85

Tested by 1

test_Polygon_closeFunction · 0.76