Set the vertices of the polygons. Parameters ---------- verts : list of array-like The sequence of polygons [*verts0*, *verts1*, ...] where each element *verts_i* defines the vertices of polygon *i* as a 2D array-like of shape (M,
(self, verts, closed=True)
| 1325 | self.stale = True |
| 1326 | |
| 1327 | def set_verts(self, verts, closed=True): |
| 1328 | """ |
| 1329 | Set the vertices of the polygons. |
| 1330 | |
| 1331 | Parameters |
| 1332 | ---------- |
| 1333 | verts : list of array-like |
| 1334 | The sequence of polygons [*verts0*, *verts1*, ...] where each |
| 1335 | element *verts_i* defines the vertices of polygon *i* as a 2D |
| 1336 | array-like of shape (M, 2). |
| 1337 | closed : bool, default: True |
| 1338 | Whether the polygon should be closed by adding a CLOSEPOLY |
| 1339 | connection at the end. |
| 1340 | """ |
| 1341 | self.stale = True |
| 1342 | if isinstance(verts, np.ma.MaskedArray): |
| 1343 | verts = verts.astype(float).filled(np.nan) |
| 1344 | |
| 1345 | # No need to do anything fancy if the path isn't closed. |
| 1346 | if not closed: |
| 1347 | self._paths = [mpath.Path(xy) for xy in verts] |
| 1348 | return |
| 1349 | |
| 1350 | # Fast path for arrays |
| 1351 | if isinstance(verts, np.ndarray) and len(verts.shape) == 3 and verts.size: |
| 1352 | verts_pad = np.concatenate((verts, verts[:, :1]), axis=1) |
| 1353 | # It's faster to create the codes and internal flags once in a |
| 1354 | # template path and reuse them. |
| 1355 | template_path = mpath.Path(verts_pad[0], closed=True) |
| 1356 | codes = template_path.codes |
| 1357 | _make_path = mpath.Path._fast_from_codes_and_verts |
| 1358 | self._paths = [_make_path(xy, codes, internals_from=template_path) |
| 1359 | for xy in verts_pad] |
| 1360 | return |
| 1361 | |
| 1362 | self._paths = [] |
| 1363 | for xy in verts: |
| 1364 | if len(xy): |
| 1365 | self._paths.append(mpath.Path._create_closed(xy)) |
| 1366 | else: |
| 1367 | self._paths.append(mpath.Path(xy)) |
| 1368 | |
| 1369 | set_paths = set_verts |
| 1370 |
no test coverage detected