Set the data values. Parameters ---------- A : array-like The mesh data. Supported array shapes are: - (M, N) or (M*N,): a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameter
(self, A)
| 2358 | self._shading = shading |
| 2359 | |
| 2360 | def set_array(self, A): |
| 2361 | """ |
| 2362 | Set the data values. |
| 2363 | |
| 2364 | Parameters |
| 2365 | ---------- |
| 2366 | A : array-like |
| 2367 | The mesh data. Supported array shapes are: |
| 2368 | |
| 2369 | - (M, N) or (M*N,): a mesh with scalar data. The values are mapped |
| 2370 | to colors using normalization and a colormap. See parameters |
| 2371 | *norm*, *cmap*, *vmin*, *vmax*. |
| 2372 | - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). |
| 2373 | - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), |
| 2374 | i.e. including transparency. |
| 2375 | |
| 2376 | If the values are provided as a 2D grid, the shape must match the |
| 2377 | coordinates grid. If the values are 1D, they are reshaped to 2D. |
| 2378 | M, N follow from the coordinates grid, where the coordinates grid |
| 2379 | shape is (M, N) for 'gouraud' *shading* and (M+1, N+1) for 'flat' |
| 2380 | shading. |
| 2381 | """ |
| 2382 | height, width = self._coordinates.shape[0:-1] |
| 2383 | if self._shading == 'flat': |
| 2384 | h, w = height - 1, width - 1 |
| 2385 | else: |
| 2386 | h, w = height, width |
| 2387 | ok_shapes = [(h, w, 3), (h, w, 4), (h, w), (h * w,)] |
| 2388 | if A is not None: |
| 2389 | shape = np.shape(A) |
| 2390 | if shape not in ok_shapes: |
| 2391 | raise ValueError( |
| 2392 | f"For X ({width}) and Y ({height}) with {self._shading} " |
| 2393 | f"shading, A should have shape " |
| 2394 | f"{' or '.join(map(str, ok_shapes))}, not {A.shape}") |
| 2395 | return super().set_array(A) |
| 2396 | |
| 2397 | def get_coordinates(self): |
| 2398 | """ |