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

Method update_scalarmappable

lib/matplotlib/collections.py:1012–1048  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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."""

Callers 13

drawMethod · 0.95
set_3d_propertiesMethod · 0.80
set_3d_propertiesMethod · 0.80
set_3d_propertiesMethod · 0.80
do_3d_projectionMethod · 0.80
drawMethod · 0.80
drawMethod · 0.80
changedMethod · 0.80
_process_colorsMethod · 0.80
test_alpha_validationFunction · 0.80
test_color_logicFunction · 0.80

Calls 4

_set_mappable_flagsMethod · 0.95
_set_facecolorMethod · 0.95
_set_edgecolorMethod · 0.95
to_rgbaMethod · 0.45

Tested by 4

test_alpha_validationFunction · 0.64
test_color_logicFunction · 0.64
test_array_dimensionsFunction · 0.64