LUTSIZE = mpl.rcParams['image.lut'] _cmapnames = datad.keys() # need this list because datad is changed in loop # Generate the reversed specifications ... for cmapname in _cmapnames: spec = datad[cmapname] spec_reversed = _reverse_cmap_spec(spec) datad[cmapname + '_r'] = spec_reversed # Precache the cmaps with ``lutsize = LUTSIZE`` ... # Use datad.keys() to also add the reversed ones added in the section above: for cmapname in datad.iterkeys(): cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE) locals().update(cmap_d) # Continue with definitions ... def register_cmap(name=None, cmap=None, data=None, lut=None): """ Add a colormap to the set recognized by :func:`get_cmap`. It can be used in two ways:: register_cmap(name='swirly', cmap=swirly_cmap)
LUTSIZE = mpl.rcParams['image.lut'] _cmapnames = datad.keys() # need this list because datad is changed in loop # Generate the reversed specifications ... for cmapname in _cmapnames: spec = datad[cmapname] spec_reversed = _reverse_cmap_spec(spec) datad[cmapname + '_r'] = spec_reversed # Precache the cmaps with ``lutsize = LUTSIZE`` ... # Use datad.keys() to also add the reversed ones added in the section above: for cmapname in datad.iterkeys(): cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE) locals().update(cmap_d) # Continue with definitions ... def register_cmap(name=None, cmap=None, data=None, lut=None): """ Add a colormap to the set recognized by :func:`get_cmap`. It can be used in two ways:: register_cmap(name='swirly', cmap=swirly_cmap) register_cmap(name='choppy', data=choppydata, lut=128)