make_mapping_array¶

make_mapping_array
(N, data, gamma=1.0, inverse=False)[source]¶ Similar to
makeMappingArray
but permits circular hue gradations along 0360, disables clipping of outofbounds channel values, and uses fancier “gamma” scaling. Parameters
N (int) – Number of points in the colormap lookup table.
data (2D arraylike) – List of \((x, y_0, y_1)\) tuples specifying the channel jump (from \(y_0\) to \(y_1\)) and the \(x\) coordinate of that transition (ranges between 0 and 1). See
LinearSegmentedColormap
for details.gamma (float or list of float, optional) – To obtain channel values between coordinates \(x_i\) and \(x_{i+1}\) in rows \(i\) and \(i+1\) of
data
, we use the formula:\[y = y_{1,i} + w_i^{\gamma_i}*(y_{0,i+1}  y_{1,i})\]where \(\gamma_i\) corresponds to
gamma
and the weight \(w_i\) ranges from 0 to 1 between rowsi
andi+1
. Ifgamma
is float, it applies to every transition. Otherwise, its length must equaldata.shape[0]1
.This is like the
gamma
used with matplotlib’smakeMappingArray
, except it controls the weighting for transitions between each segment data coordinate rather than the coordinates themselves. This makes more sense forPerceptuallyUniformColormap
\ s because they usually consist of just one linear transition for sequential colormaps and two linear transitions for diverging colormaps – and in the latter case, it is often desirable to modify both “halves” of the colormap in the same way.inverse (bool, optional) – If
True
, \(w_i^{\gamma_i}\) is replaced with \(1  (1  w_i)^{\gamma_i}\) – that is, whengamma
is greater than 1, this weights colors toward higher channel values instead of lower channel values.This is implemented in case we want to apply equal “gamma scaling” to different HSL channels in different directions. Usually, this is done to weight low data values with higher luminance and lower saturation, thereby emphasizing “extreme” data values with stronger colors.