2424import numpy as np
2525from numpy import ma
2626
27- from matplotlib import _api , colors , cbook , artist , cm , scale
27+ from matplotlib import _api , colors , cbook , artist , scale
2828import matplotlib as mpl
2929
3030mpl ._docstring .interpd .register (
@@ -222,9 +222,9 @@ def _set_cmap(self, cmap):
222222 in_init = self ._cmap is None
223223 cmap_obj = _ensure_cmap (cmap , accept_multivariate = True )
224224 if not in_init and self .norm .n_components != cmap_obj .n_variates :
225- raise ValueError (f"The colormap { cmap } does not support "
226- f"{ self .norm .n_components } variates as required by "
227- f"the { type (self .norm )} on this Colorizer" )
225+ raise ValueError (f"The colormap { cmap } does not support "
226+ f"{ self .norm .n_components } variates as required by "
227+ f"the { type (self .norm )} on this Colorizer" )
228228 self ._cmap = cmap_obj
229229 if not in_init :
230230 self .changed () # Things are not set up properly yet.
@@ -814,7 +814,8 @@ def _ensure_cmap(cmap, accept_multivariate=False):
814814 if isinstance (cmap , types ):
815815 return cmap
816816
817- cmap_name = cmap if cmap is not None else mpl .rcParams ["image.cmap" ]
817+ cmap_name = mpl ._val_or_rc (cmap , "image.cmap" )
818+
818819 for mapping in mappings :
819820 if cmap_name in mapping :
820821 return mapping [cmap_name ]
@@ -829,8 +830,6 @@ def _ensure_cmap(cmap, accept_multivariate=False):
829830 " `matplotlib.multivar_colormaps()` for"
830831 " bivariate and multivariate colormaps" )
831832
832- return cm .colormaps [cmap_name ]
833-
834833
835834def _ensure_multivariate_data (data , n_components ):
836835 """
@@ -870,7 +869,8 @@ def _ensure_multivariate_data(data, n_components):
870869 dt = np .dtype ('float64, float64' )
871870 else :
872871 dt = np .dtype ('float32, float32' )
873- reconstructed = np .ma .frombuffer (data .data , dtype = dt ).reshape (data .shape )
872+
873+ reconstructed = np .ma .array (np .asarray (data ).view (dt ))
874874 if np .ma .is_masked (data ):
875875 for descriptor in dt .descr :
876876 reconstructed [descriptor [0 ]][data .mask ] = np .ma .masked
0 commit comments