Skip to content

Commit 703343e

Browse files
committed
Override ScalarMappable set_array for Collection
1 parent 59bfcfa commit 703343e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/collections.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,23 @@ def set_alpha(self, alpha):
849849

850850
set_alpha.__doc__ = artist.Artist._set_alpha_for_array.__doc__
851851

852+
def set_array(self, A):
853+
"""
854+
Set the image array.
855+
856+
Parameters
857+
----------
858+
A : array-like
859+
"""
860+
# This method overrides the inherited
861+
# cm.ScalarMappable.set_array method
862+
self._A = cbook.safe_masked_invalid(A, copy=True)
863+
864+
if (self._A.dtype != np.uint8 and
865+
not np.can_cast(self._A.dtype, float, "same_kind")):
866+
raise TypeError("Image data of dtype {} cannot be converted to "
867+
"float".format(self._A.dtype))
868+
852869
def get_linewidth(self):
853870
return self._linewidths
854871

0 commit comments

Comments
 (0)