# matplotlib.colors.makeMappingArray¶

matplotlib.colors.makeMappingArray(N, data, gamma=1.0)[source]

Create an N -element 1-d lookup table.

This assumes a mapping $$f : [0, 1] \rightarrow [0, 1]$$. The returned data is an array of N values $$y = f(x)$$ where x is sampled from [0, 1].

By default (gamma = 1) x is equidistantly sampled from [0, 1]. The gamma correction factor $$\gamma$$ distorts this equidistant sampling by $$x \rightarrow x^\gamma$$.

Parameters: N : int The number of elements of the created lookup table. This must be N >= 1. data : Mx3 array-like or callable Defines the mapping $$f$$. If a Mx3 array-like, the rows define values (x, y0, y1). The x values must start with x=0, end with x=1, and all x values be in increasing order. A value between $$x_i$$ and $$x_{i+1}$$ is mapped to the range $$y^1_{i-1} \ldots y^0_i$$ by linear interpolation. For the simple case of a y-continuous mapping, y0 and y1 are identical. The two values of y are to allow for discontinuous mapping functions. E.g. a sawtooth with a period of 0.2 and an amplitude of 1 would be: [(0, 1, 0), (0.2, 1, 0), (0.4, 1, 0), ..., [(1, 1, 0)]  In the special case of N == 1, by convention the returned value is y0 for x == 1. If data is a callable, it must accept and return numpy arrays: data(x : ndarray) -> ndarray  and map values between 0 - 1 to 0 - 1. gamma : float Gamma correction factor for input distribution x of the mapping. lut : array The lookup table where lut[x * (N-1)] gives the closest value for values of x between 0 and 1.

Notes

This function is internally used for LinearSegmentedColormaps.