(self, renderer, magnification=1.0, unsampled=False)
| 1252 | self.set_data(x, y, A) |
| 1253 | |
| 1254 | def make_image(self, renderer, magnification=1.0, unsampled=False): |
| 1255 | # docstring inherited |
| 1256 | if self._A is None: |
| 1257 | raise RuntimeError('You must first set the image array') |
| 1258 | if unsampled: |
| 1259 | raise ValueError('unsampled not supported on PColorImage') |
| 1260 | |
| 1261 | if self._imcache is None: |
| 1262 | A = self.to_rgba(self._A, bytes=True) |
| 1263 | self._imcache = np.pad(A, [(1, 1), (1, 1), (0, 0)], "constant") |
| 1264 | padded_A = self._imcache |
| 1265 | bg = mcolors.to_rgba(self.axes.patch.get_facecolor(), 0) |
| 1266 | bg = (np.array(bg) * 255).astype(np.uint8) |
| 1267 | if (padded_A[0, 0] != bg).all(): |
| 1268 | padded_A[[0, -1], :] = padded_A[:, [0, -1]] = bg |
| 1269 | |
| 1270 | # Round to the nearest output pixels after magnification |
| 1271 | l, b, r, t = (self.axes.bbox.extents * magnification + 0.5).astype(int) |
| 1272 | width = r - l |
| 1273 | height = t - b |
| 1274 | |
| 1275 | vl = self.axes.viewLim |
| 1276 | |
| 1277 | x_pix_edges = np.linspace(vl.x0, vl.x1, width + 1) |
| 1278 | y_pix_edges = np.linspace(vl.y0, vl.y1, height + 1) |
| 1279 | x_pix_centers = (x_pix_edges[:-1] + x_pix_edges[1:]) / 2 |
| 1280 | y_pix_centers = (y_pix_edges[:-1] + y_pix_edges[1:]) / 2 |
| 1281 | x_int = self._Ax.searchsorted(x_pix_centers) |
| 1282 | y_int = self._Ay.searchsorted(y_pix_centers) |
| 1283 | im = ( # See comment in NonUniformImage.make_image re: performance. |
| 1284 | padded_A.view(np.uint32).ravel()[ |
| 1285 | np.add.outer(y_int * padded_A.shape[1], x_int)] |
| 1286 | .view(np.uint8).reshape((height, width, 4))) |
| 1287 | return im, l / magnification, b / magnification, IdentityTransform() |
| 1288 | |
| 1289 | def _check_unsampled_image(self): |
| 1290 | return False |
nothing calls this directly
no test coverage detected