A class for converting color arguments to RGB or RGBA
This class instantiates a single instance colorConverter that is used to convert matlab color strings to RGB. RGB is a tuple of float RGB values in the range 0-1.
Commands which take color arguments can use several formats to specify the colors. For the basic builtin colors, you can use a single letter
b : blue g : green r : red c : cyan m : magenta y : yellow k : black w : white
Gray shades can be given as a string encoding a float in the 0-1 range, e.g.:
color = '0.75'
For a greater range of colors, you have two options. You can specify the color using an html hex string, as in:
color = '#eeefff'
or you can pass an R , G , B tuple, where each of R , G , B are in the range [0,1].
Finally, legal html names for colors, like ‘red’, ‘burlywood’ and ‘chartreuse’ are supported.
Bases: matplotlib.colors.Normalize
Generate a colormap index based on discrete intervals.
Unlike Normalize or LogNorm, BoundaryNorm maps values to integers instead of to the interval 0-1.
Mapping to the 0-1 interval could have been done via piece-wise linear interpolation, but using integers seems simpler, and reduces the number of conversions back and forth between integer and floating point.
If:
b[i] <= v < b[i+1]
then v is mapped to color j; as i varies from 0 to len(boundaries)-2, j goes from 0 to ncolors-1.
Out-of-range values are mapped to -1 if low and ncolors if high; these are converted to valid indices by Colormap.__call__() .
Returns an RGB tuple of three floats from 0-1.
arg can be an RGB or RGBA sequence or a string in any of several forms:
- a letter from the set ‘rgbcmykw’
- a hex color string, like ‘#00FFFF’
- a standard name, like ‘aqua’
- a float, like ‘0.4’, indicating gray on a 0-1 scale
if arg is RGBA, the A will simply be discarded.
Returns an RGBA tuple of four floats from 0-1.
For acceptable values of arg, see to_rgb(). If arg is an RGBA sequence and alpha is not None, alpha will replace the original A.
Returns an Numpy array of RGBA tuples.
Accepts a single mpl color spec or a sequence of specs. If the sequence is a list or array, the items are changed in place, but an array copy is still returned.
Special case to handle “no color”: if c is “none” (case-insensitive), then an empty array will be returned. Same for an empty list.
Base class for all scalar to rgb mappings
Important methods:
Bases: matplotlib.colors.Colormap
Colormap objects based on lookup tables using linear segments.
The lookup transfer function is a simple linear function between defined intensities. There is no limit to the number of segments that may be defined. Though as the segment intervals start containing fewer and fewer array locations, there will be inevitable quantization errors
Create color map from linear mapping segments
segmentdata argument is a dictionary with a red, green and blue entries. Each entry should be a list of x, y0, y1 tuples. See makeMappingArray for details
Bases: matplotlib.colors.Colormap
Colormap object generated from a list of colors.
This may be most useful when indexing directly into a colormap, but it can also be used to generate special colormaps for ordinary mapping.
Make a colormap from a list of colors.
the number of entries in the map. The default is None, in which case there is one colormap entry for each element in the list of colors. If:
N < len(colors)
the list will be truncated at N. If:
N > len(colors)
the list will be extended by repetition.
Bases: matplotlib.colors.Normalize
Normalize a given value to the 0-1 range on a log scale
If vmin or vmax is not given, they are taken from the input’s minimum and maximum value respectively. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. Returns 0 if:
vmin==vmax
Works with scalars or arrays, including masked arrays. If clip is True, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is clip = False.
Bases: matplotlib.colors.Normalize
Dummy replacement for Normalize, for the case where we want to use indices directly in a ScalarMappable .
If vmin or vmax is not given, they are taken from the input’s minimum and maximum value respectively. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. Returns 0 if:
vmin==vmax
Works with scalars or arrays, including masked arrays. If clip is True, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is clip = False.
Normalize a given value to the 0-1 range
If vmin or vmax is not given, they are taken from the input’s minimum and maximum value respectively. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. Returns 0 if:
vmin==vmax
Works with scalars or arrays, including masked arrays. If clip is True, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is clip = False.
Create an N -element 1-d lookup table
data represented by a list of x,y0,y1 mapping correspondences. Each element in this list represents how a value between 0 and 1 (inclusive) represented by x is mapped to a corresponding value between 0 and 1 (inclusive). The two values of y are to allow for discontinuous mapping functions (say as might be found in a sawtooth) where y0 represents the value of y for values of x <= to that given, and y1 is the value to be used for x > than that given). The list must start with x=0, end with x=1, and all values of x must be in increasing order. Values between the given mapping points are determined by simple linear interpolation.
The function returns an array “result” where result[x*(N-1)] gives the closest value for values of x between 0 and 1.
Bases: matplotlib.colors.Normalize
Dummy replacement for Normalize, for the case where we want to use indices directly in a ScalarMappable .
If vmin or vmax is not given, they are taken from the input’s minimum and maximum value respectively. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. Returns 0 if:
vmin==vmax
Works with scalars or arrays, including masked arrays. If clip is True, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is clip = False.
Normalize a given value to the 0-1 range
If vmin or vmax is not given, they are taken from the input’s minimum and maximum value respectively. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. Returns 0 if:
vmin==vmax
Works with scalars or arrays, including masked arrays. If clip is True, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is clip = False.