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

Method _set_transforms

lib/matplotlib/collections.py:2131–2171  ·  view source on GitHub ↗

Calculate transforms immediately before drawing.

(self)

Source from the content-addressed store, hash-verified

2129 self._paths = [mpath.Path.unit_circle()]
2130
2131 def _set_transforms(self):
2132 """Calculate transforms immediately before drawing."""
2133
2134 ax = self.axes
2135 fig = self.get_figure(root=False)
2136
2137 if self._units == 'xy':
2138 sc = 1
2139 elif self._units == 'x':
2140 sc = ax.bbox.width / ax.viewLim.width
2141 elif self._units == 'y':
2142 sc = ax.bbox.height / ax.viewLim.height
2143 elif self._units == 'inches':
2144 sc = fig.dpi
2145 elif self._units == 'points':
2146 sc = fig.dpi / 72.0
2147 elif self._units == 'width':
2148 sc = ax.bbox.width
2149 elif self._units == 'height':
2150 sc = ax.bbox.height
2151 elif self._units == 'dots':
2152 sc = 1.0
2153 else:
2154 raise ValueError(f'Unrecognized units: {self._units!r}')
2155
2156 self._transforms = np.zeros((len(self._widths), 3, 3))
2157 widths = self._widths * sc
2158 heights = self._heights * sc
2159 sin_angle = np.sin(self._angles)
2160 cos_angle = np.cos(self._angles)
2161 self._transforms[:, 0, 0] = widths * cos_angle
2162 self._transforms[:, 0, 1] = heights * -sin_angle
2163 self._transforms[:, 1, 0] = widths * sin_angle
2164 self._transforms[:, 1, 1] = heights * cos_angle
2165 self._transforms[:, 2, 2] = 1.0
2166
2167 _affine = transforms.Affine2D
2168 if self._units == 'xy':
2169 m = ax.transData.get_affine().get_matrix().copy()
2170 m[:2, 2:] = 0
2171 self.set_transform(_affine(m))
2172
2173 def set_widths(self, widths):
2174 """Set the lengths of the first axes (e.g., major axis)."""

Callers 1

drawMethod · 0.95

Calls 5

get_figureMethod · 0.45
copyMethod · 0.45
get_matrixMethod · 0.45
get_affineMethod · 0.45
set_transformMethod · 0.45

Tested by

no test coverage detected