Update colors from the scalar mappable array, if any. Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.
(self)
| 1010 | return mapped or changed |
| 1011 | |
| 1012 | def update_scalarmappable(self): |
| 1013 | """ |
| 1014 | Update colors from the scalar mappable array, if any. |
| 1015 | |
| 1016 | Assign colors to edges and faces based on the array and/or |
| 1017 | colors that were directly set, as appropriate. |
| 1018 | """ |
| 1019 | if not self._set_mappable_flags(): |
| 1020 | return |
| 1021 | # Allow possibility to call 'self.set_array(None)'. |
| 1022 | if self._A is not None: |
| 1023 | # QuadMesh can map 2d arrays (but pcolormesh supplies 1d array) |
| 1024 | if self._A.ndim > 1 and not isinstance(self, _MeshData): |
| 1025 | raise ValueError('Collections can only map rank 1 arrays') |
| 1026 | if np.iterable(self._alpha): |
| 1027 | if self._alpha.size != self._A.size: |
| 1028 | raise ValueError( |
| 1029 | f'Data array shape, {self._A.shape} ' |
| 1030 | 'is incompatible with alpha array shape, ' |
| 1031 | f'{self._alpha.shape}. ' |
| 1032 | 'This can occur with the deprecated ' |
| 1033 | 'behavior of the "flat" shading option, ' |
| 1034 | 'in which a row and/or column of the data ' |
| 1035 | 'array is dropped.') |
| 1036 | # pcolormesh, scatter, maybe others flatten their _A |
| 1037 | self._alpha = self._alpha.reshape(self._A.shape) |
| 1038 | self._mapped_colors = self.to_rgba(self._A, self._alpha) |
| 1039 | |
| 1040 | if self._face_is_mapped: |
| 1041 | self._facecolors = self._mapped_colors |
| 1042 | else: |
| 1043 | self._set_facecolor(self._original_facecolor) |
| 1044 | if self._edge_is_mapped: |
| 1045 | self._edgecolors = self._mapped_colors |
| 1046 | else: |
| 1047 | self._set_edgecolor(self._original_edgecolor) |
| 1048 | self.stale = True |
| 1049 | |
| 1050 | def get_fill(self): |
| 1051 | """Return whether face is colored.""" |