xoa.color.CmapAdapter#
- class xoa.color.CmapAdapter(cmap, specs=None)[source]#
Adapt a given colormap to data
- Parameters:
cmap – The colormap to adapt
specs (str, None) –
Transformation specifications or None.
When a string, it must have the format
"<type><value>", where type is"piv"or"cyc", and value is convertible to a float.If type is
"piv", that colormap is expected typically to be diverging, and is cropped usingcrop_cmap(), after min and max value are set withset_vlim().If type is
"cyc", min is set to 0 and max tovalue, and the colormap is expected to be circular, like"cmo.phase".
Example
In [1]: cma = CmapAdapter('cmo.balance', 'piv0') In [2]: data = np.arange(100).reshape(10, 10) - 20 In [3]: cma.set_vlim(data.min(), data.max()) Out[3]: (np.int64(-20), np.int64(79)) In [4]: plt.contourf(data, **cma.get_dict()); In [5]: plt.colorbar();
Methods