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):
222222in_init = self ._cmap is None
223223cmap_obj = _ensure_cmap (cmap ,accept_multivariate = True )
224224if 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" )
228228self ._cmap = cmap_obj
229229if not in_init :
230230self .changed ()# Things are not set up properly yet.
@@ -814,7 +814,8 @@ def _ensure_cmap(cmap, accept_multivariate=False):
814814if isinstance (cmap ,types ):
815815return 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+
818819for mapping in mappings :
819820if cmap_name in mapping :
820821return 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):
870869dt = np .dtype ('float64, float64' )
871870else :
872871dt = 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 ))
874874if np .ma .is_masked (data ):
875875for descriptor in dt .descr :
876876reconstructed [descriptor [0 ]][data .mask ]= np .ma .masked