MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / __init__

Method __init__

lib/matplotlib/colors.py:1088–1162  ·  view source on GitHub ↗

Create colormap from linear mapping segments. Parameters ---------- name : str The name of the colormap. segmentdata : dict A dictionary with keys "red", "green", "blue" for the color channels. Each entry should be a list

(self, name, segmentdata, N=256, gamma=1.0, *,
                 bad=None, under=None, over=None)

Source from the content-addressed store, hash-verified

1086 """
1087
1088 def __init__(self, name, segmentdata, N=256, gamma=1.0, *,
1089 bad=None, under=None, over=None):
1090 """
1091 Create colormap from linear mapping segments.
1092
1093 Parameters
1094 ----------
1095 name : str
1096 The name of the colormap.
1097 segmentdata : dict
1098 A dictionary with keys "red", "green", "blue" for the color channels.
1099 Each entry should be a list of *x*, *y0*, *y1* tuples, forming rows
1100 in a table. Entries for alpha are optional.
1101
1102 Example: suppose you want red to increase from 0 to 1 over
1103 the bottom half, green to do the same over the middle half,
1104 and blue over the top half. Then you would use::
1105
1106 {
1107 'red': [(0.0, 0.0, 0.0),
1108 (0.5, 1.0, 1.0),
1109 (1.0, 1.0, 1.0)],
1110 'green': [(0.0, 0.0, 0.0),
1111 (0.25, 0.0, 0.0),
1112 (0.75, 1.0, 1.0),
1113 (1.0, 1.0, 1.0)],
1114 'blue': [(0.0, 0.0, 0.0),
1115 (0.5, 0.0, 0.0),
1116 (1.0, 1.0, 1.0)]
1117 }
1118
1119 Each row in the table for a given color is a sequence of
1120 *x*, *y0*, *y1* tuples. In each sequence, *x* must increase
1121 monotonically from 0 to 1. For any input value *z* falling
1122 between *x[i]* and *x[i+1]*, the output value of a given color
1123 will be linearly interpolated between *y1[i]* and *y0[i+1]*::
1124
1125 row i: x y0 y1
1126 /
1127 /
1128 row i+1: x y0 y1
1129
1130 Hence, y0 in the first row and y1 in the last row are never used.
1131
1132 N : int
1133 The number of RGB quantization levels.
1134 gamma : float
1135 Gamma correction factor for input distribution x of the mapping.
1136 See also https://en.wikipedia.org/wiki/Gamma_correction.
1137 bad : :mpltype:`color`, default: transparent
1138 The color for invalid values (NaN or masked).
1139
1140 .. versionadded:: 3.11
1141
1142 under : :mpltype:`color`, default: color of the lowest value
1143 The color for low out-of-range values.
1144
1145 .. versionadded:: 3.11

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected