matplotlib 3.5.1

NotesParametersReturns
_create_lookup_table(N, data, gamma=1.0)

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$ .

Notes

This function is internally used for .LinearSegmentedColormap .

Parameters

N : int

The number of elements of the created lookup table; at least 1.

data : (M, 3) array-like or callable

Defines the mapping $f$ .

If a (M, 3) 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.

See also https://en.wikipedia.org/wiki/Gamma_correction.

Returns

array

The lookup table where lut[x * (N-1)] gives the closest value for values of x between 0 and 1.

Create an N -element 1D lookup table.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/colors.py#439
type: <class 'function'>
Commit: