apply_colormap
apply_colormap(C, f, min=None, max=None, log=False, piecewise_linear=False)
Maps function values to colors of a given colormap.
Apply a colormap produced with the colormap function to an array of scalar values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C |
numpy int array
|
Colormap matrix where each row corresponds to an RGB color. Compatible with maps produced by colormap |
required |
f |
numpy double array
|
Vector of scalar function values to which to apply the colormap |
required |
min |
double, optional (default None)
|
Scalar value corresponding to the beginning of C. Will auto-scale if None. |
None
|
max |
double, optional (default None)
|
Scalar value corresponding to the end of C. Will auto-scale if None. |
None
|
log |
bool, optional (default False)
|
Whether to log-scale the colormap or not. For this option, all values will be clamped to larger than machine epsilon. |
False
|
piecewise_linear |
bool, optional (default False)
|
Whether to treat the colormap as piecewise linear |
False
|
Returns:
Name | Type | Description |
---|---|---|
f_colored |
numpy double array
|
Matrix of C applied to f. Each row corresponds to a scalar value in f. |
See Also
colormap.
Notes
All colormaps are assumed to be piecewise constant unless otherwise specified (be aware: the first and last colors of the colormap will span half as much length as the other colors, since they represent the colors at the minimum and maximum respectively).
Examples:
from gpytoolbox import apply_colormap, colormap
map_name = 'RdBu'
# Some random values
scalar_values = np.random.rand(100)
# Convert them into colors using the given map with 60 steps
C = apply_colormap(colormap(map, 60), scalar_values)
Source code in src/gpytoolbox/apply_colormap.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|