cmap
cmap(
data,robust?,cmapSeq?,cmapBool?,cmapDiv?):any
Defined in: packages/pleco-xa/src/scripts/xa-display.js:107
Get a default colormap from the given data
Determines an appropriate colormap based on data characteristics:
- Sequential colormaps for non-negative data
- Boolean colormaps for binary data
- Diverging colormaps for centered data
Parameters
Section titled “Parameters”any[] | Float32Array<ArrayBufferLike> | number[][]
Input data (1D or 2D array)
robust?
Section titled “robust?”boolean = true
If true, use 2nd/98th percentiles for range detection
cmapSeq?
Section titled “cmapSeq?”string = 'magma'
Sequential colormap name (default: ‘magma’)
cmapBool?
Section titled “cmapBool?”string = 'gray_r'
Boolean colormap name (default: ‘gray_r’)
cmapDiv?
Section titled “cmapDiv?”string = 'coolwarm'
Diverging colormap name (default: ‘coolwarm’)
Returns
Section titled “Returns”any
Colormap configuration with {type, name, colors, map function}
Examples
Section titled “Examples”// Sequential data (spectrogram)const spec = new Float32Array([0.1, 0.5, 0.9, 1.2]);const cmap = cmap(spec); // Returns 'magma' sequential colormap// Centered data (chromagram difference)const diff = new Float32Array([-1.0, -0.5, 0.0, 0.5, 1.0]);const cmap = cmap(diff, true, 'magma', 'gray_r', 'coolwarm'); // Returns 'coolwarm' diverging