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

Method _make_verts

lib/matplotlib/patches.py:1608–1668  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1606 self.set_xy(self.verts)
1607
1608 def _make_verts(self):
1609 if self._head_width is None:
1610 head_width = 3 * self._width
1611 else:
1612 head_width = self._head_width
1613 if self._head_length is None:
1614 head_length = 1.5 * head_width
1615 else:
1616 head_length = self._head_length
1617
1618 distance = np.hypot(self._dx, self._dy)
1619
1620 if self._length_includes_head:
1621 length = distance
1622 else:
1623 length = distance + head_length
1624 if np.size(length) == 0:
1625 self.verts = np.empty([0, 2]) # display nothing if empty
1626 else:
1627 # start by drawing horizontal arrow, point at (0, 0)
1628 hw, hl = head_width, head_length
1629 hs, lw = self._overhang, self._width
1630 left_half_arrow = np.array([
1631 [0.0, 0.0], # tip
1632 [-hl, -hw / 2], # leftmost
1633 [-hl * (1 - hs), -lw / 2], # meets stem
1634 [-length, -lw / 2], # bottom left
1635 [-length, 0],
1636 ])
1637 # if we're not including the head, shift up by head length
1638 if not self._length_includes_head:
1639 left_half_arrow += [head_length, 0]
1640 # if the head starts at 0, shift up by another head length
1641 if self._head_starts_at_zero:
1642 left_half_arrow += [head_length / 2, 0]
1643 # figure out the shape, and complete accordingly
1644 if self._shape == 'left':
1645 coords = left_half_arrow
1646 else:
1647 right_half_arrow = left_half_arrow * [1, -1]
1648 if self._shape == 'right':
1649 coords = right_half_arrow
1650 elif self._shape == 'full':
1651 # The half-arrows contain the midpoint of the stem,
1652 # which we can omit from the full arrow. Including it
1653 # twice caused a problem with xpdf.
1654 coords = np.concatenate([left_half_arrow[:-1],
1655 right_half_arrow[-2::-1]])
1656 else:
1657 raise ValueError(f"Got unknown shape: {self._shape!r}")
1658 if distance != 0:
1659 cx = self._dx / distance
1660 sx = self._dy / distance
1661 else:
1662 # Account for division by zero
1663 cx, sx = 0, 1
1664 M = [[cx, sx], [-sx, cx]]
1665 self.verts = np.dot(coords, M) + [

Callers 2

__init__Method · 0.95
set_dataMethod · 0.95

Calls 2

sizeMethod · 0.80
dotMethod · 0.80

Tested by

no test coverage detected