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

Class Wedge

lib/matplotlib/patches.py:1332–1415  ·  view source on GitHub ↗

Wedge shaped patch.

Source from the content-addressed store, hash-verified

1330
1331
1332class Wedge(Patch):
1333 """Wedge shaped patch."""
1334
1335 def __str__(self):
1336 pars = (self.center[0], self.center[1], self.r,
1337 self.theta1, self.theta2, self.width)
1338 fmt = "Wedge(center=(%g, %g), r=%g, theta1=%g, theta2=%g, width=%s)"
1339 return fmt % pars
1340
1341 @_docstring.interpd
1342 def __init__(self, center, r, theta1, theta2, *, width=None, **kwargs):
1343 """
1344 A wedge centered at *x*, *y* center with radius *r* that
1345 sweeps *theta1* to *theta2* (in degrees). If *width* is given,
1346 then a partial wedge is drawn from inner radius *r* - *width*
1347 to outer radius *r*.
1348
1349 Valid keyword arguments are:
1350
1351 %(Patch:kwdoc)s
1352 """
1353 super().__init__(**kwargs)
1354 self.center = center
1355 self.r, self.width = r, width
1356 self.theta1, self.theta2 = theta1, theta2
1357 self._patch_transform = transforms.IdentityTransform()
1358 self._recompute_path()
1359
1360 def _recompute_path(self):
1361 # Inner and outer rings are connected unless the annulus is complete
1362 if abs((self.theta2 - self.theta1) - 360) <= 1e-12:
1363 theta1, theta2 = 0, 360
1364 connector = Path.MOVETO
1365 else:
1366 theta1, theta2 = self.theta1, self.theta2
1367 connector = Path.LINETO
1368
1369 # Form the outer ring
1370 arc = Path.arc(theta1, theta2)
1371
1372 if self.width is not None:
1373 # Partial annulus needs to draw the outer ring
1374 # followed by a reversed and scaled inner ring
1375 v1 = arc.vertices
1376 v2 = arc.vertices[::-1] * (self.r - self.width) / self.r
1377 v = np.concatenate([v1, v2, [(0, 0)]])
1378 c = [*arc.codes, connector, *arc.codes[1:], Path.CLOSEPOLY]
1379 else:
1380 # Wedge doesn't need an inner ring
1381 v = np.concatenate([arc.vertices, [(0, 0), (0, 0)]])
1382 c = [*arc.codes, connector, Path.CLOSEPOLY]
1383
1384 # Shift and scale the wedge to the final location.
1385 self._path = Path(v * self.r + self.center, c)
1386
1387 def set_center(self, center):
1388 self._path = None
1389 self.center = center

Callers 2

draw_spineFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…