matplotlib.colors
index
/astro-wise/AWEHOME/x86_64/AWBASE/common/lib/python2.5/site-packages/matplotlib/colors.py

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.

 
Modules
       
matplotlib.numerix.ma
matplotlib.numerix
re
warnings

 
Classes
       
ColorConverter
Colormap
LinearSegmentedColormap
ListedColormap
Normalize
LogNorm
NoNorm
NoNorm

 
class ColorConverter
     Methods defined here:
to_rgb(self, arg)
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:
    1) a letter from the set 'rgbcmykw'
    2) a hex color string, like '#00FFFF'
    3) a standard name, like 'aqua'
    4) a float, like '0.4', indicating gray on a 0-1 scale
 
if arg is RGBA, the A will simply be discarded.
to_rgba(self, arg, alpha=None)
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.
to_rgba_list(self, c, alpha=None)
Returns a list of rgba tuples.
 
Accepts a single mpl color spec or a sequence of specs.
If the sequence is a list, the list items are changed in place.

Data and other attributes defined here:
cache = {}
colors = {'b': (0.0, 0.0, 1.0), 'c': (0.0, 0.75, 0.75), 'g': (0.0, 0.5, 0.0), 'k': (0.0, 0.0, 0.0), 'm': (0.75, 0, 0.75), 'r': (1.0, 0.0, 0.0), 'w': (1.0, 1.0, 1.0), 'y': (0.75, 0.75, 0)}

 
class Colormap
    Base class for all scalar to rgb mappings
 
Important methods:
    set_bad()
    set_under()
    set_over()
 
  Methods defined here:
__call__(self, X, alpha=1.0)
X is either a scalar or an array (of any dimension).
If scalar, a tuple of rgba values is returned, otherwise
an array with the new shape = oldshape+(4,). If the X-values
are integers, then they are used as indices into the array.
If they are floating point, then they must be in the
interval (0.0, 1.0).
Alpha must be a scalar.
__init__(self, name, N=256)
Public class attributes:
self.N:       number of rgb quantization levels
self.name:    name of colormap
is_gray(self)
set_bad(self, color='k', alpha=1.0)
Set color to be used for masked values.
set_over(self, color='k', alpha=1.0)
Set color to be used for high out-of-range values.
Requires norm.clip = False
set_under(self, color='k', alpha=1.0)
Set color to be used for low out-of-range values.
Requires norm.clip = False

 
class LinearSegmentedColormap(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
 
  Methods defined here:
__init__(self, name, segmentdata, N=256)
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

Methods inherited from Colormap:
__call__(self, X, alpha=1.0)
X is either a scalar or an array (of any dimension).
If scalar, a tuple of rgba values is returned, otherwise
an array with the new shape = oldshape+(4,). If the X-values
are integers, then they are used as indices into the array.
If they are floating point, then they must be in the
interval (0.0, 1.0).
Alpha must be a scalar.
is_gray(self)
set_bad(self, color='k', alpha=1.0)
Set color to be used for masked values.
set_over(self, color='k', alpha=1.0)
Set color to be used for high out-of-range values.
Requires norm.clip = False
set_under(self, color='k', alpha=1.0)
Set color to be used for low out-of-range values.
Requires norm.clip = False

 
class ListedColormap(LinearSegmentedColormap)
    Colormap object generated from a list of colors.
 
Color boundaries are evenly spaced.  This is intended for simulating
indexed color selection, but may be useful for generating
special colormaps also.
 
 
Method resolution order:
ListedColormap
LinearSegmentedColormap
Colormap

Methods defined here:
__init__(self, colors, name='from_list', N=None)

Methods inherited from Colormap:
__call__(self, X, alpha=1.0)
X is either a scalar or an array (of any dimension).
If scalar, a tuple of rgba values is returned, otherwise
an array with the new shape = oldshape+(4,). If the X-values
are integers, then they are used as indices into the array.
If they are floating point, then they must be in the
interval (0.0, 1.0).
Alpha must be a scalar.
is_gray(self)
set_bad(self, color='k', alpha=1.0)
Set color to be used for masked values.
set_over(self, color='k', alpha=1.0)
Set color to be used for high out-of-range values.
Requires norm.clip = False
set_under(self, color='k', alpha=1.0)
Set color to be used for low out-of-range values.
Requires norm.clip = False

 
class LogNorm(Normalize)
    Normalize a given value to the 0-1 range on a log scale
 
  Methods defined here:
__call__(self, value, clip=None)
inverse(self, value)

Methods inherited from Normalize:
__init__(self, vmin=None, vmax=None, clip=True)
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.
autoscale(self, A)
Set vmin, vmax to min, max of A.
autoscale_None(self, A)
autoscale only None-valued vmin or vmax
scaled(self)
return true if vmin and vmax set

 
class NoNorm(Normalize)
    Dummy replacement for Normalize, for the case where we
want to use indices directly in a ScalarMappable.
 
  Methods defined here:
__call__(self, value, clip=None)
inverse(self, value)

Methods inherited from Normalize:
__init__(self, vmin=None, vmax=None, clip=True)
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.
autoscale(self, A)
Set vmin, vmax to min, max of A.
autoscale_None(self, A)
autoscale only None-valued vmin or vmax
scaled(self)
return true if vmin and vmax set

 
class Normalize
    Normalize a given value to the 0-1 range
 
  Methods defined here:
__call__(self, value, clip=None)
__init__(self, vmin=None, vmax=None, clip=True)
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.
autoscale(self, A)
Set vmin, vmax to min, max of A.
autoscale_None(self, A)
autoscale only None-valued vmin or vmax
inverse(self, value)
scaled(self)
return true if vmin and vmax set

 
no_norm = class NoNorm(Normalize)
    Dummy replacement for Normalize, for the case where we
want to use indices directly in a ScalarMappable.
 
  Methods defined here:
__call__(self, value, clip=None)
inverse(self, value)

Methods inherited from Normalize:
__init__(self, vmin=None, vmax=None, clip=True)
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.
autoscale(self, A)
Set vmin, vmax to min, max of A.
autoscale_None(self, A)
autoscale only None-valued vmin or vmax
scaled(self)
return true if vmin and vmax set

 
normalize = class Normalize
    Normalize a given value to the 0-1 range
 
  Methods defined here:
__call__(self, value, clip=None)
__init__(self, vmin=None, vmax=None, clip=True)
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.
autoscale(self, A)
Set vmin, vmax to min, max of A.
autoscale_None(self, A)
autoscale only None-valued vmin or vmax
inverse(self, value)
scaled(self)
return true if vmin and vmax set

 
Functions
       
hex2color(s)
Take a hex string 's' and return the corresponding rgb 3-tuple
Example: #efefef -> (0.93725, 0.93725, 0.93725)
is_color_like(c)
makeMappingArray(N, data)
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.
putmask(...)
putmask(a, mask, values) sets a.flat[n] = values[n] for each n where
mask.flat[n] is true.  If values is not the same size of a and mask then
it will repeat.  This gives different behavior than a[mask] = values.
rgb2hex(rgb)
Given a len 3 rgb tuple of 0-1 floats, return the hex string

 
Data
        Float = 'd'
Int = 'l'
cnames = {'aliceblue': '#F0F8FF', 'antiquewhite': '#FAEBD7', 'aqua': '#00FFFF', 'aquamarine': '#7FFFD4', 'azure': '#F0FFFF', 'beige': '#F5F5DC', 'bisque': '#FFE4C4', 'black': '#000000', 'blanchedalmond': '#FFEBCD', 'blue': '#0000FF', ...}
colorConverter = <matplotlib.colors.ColorConverter instance at 0x1c44f80>
divide = <ufunc 'divide'>
hexColorPattern = <_sre.SRE_Pattern object at 0xc9cea0>
k = 'peachpuff'
rcParams = {'axes.axisbelow': False, 'axes.edgecolor': 'k', 'axes.facecolor': 'w', 'axes.formatter.limits': (-7, 7), 'axes.grid': False, 'axes.hold': True, 'axes.labelcolor': 'k', 'axes.labelsize': 12, 'axes.linewidth': 1.0, 'axes.titlesize': 14, ...}
typecodes = {'Character': 'c', 'Complex': 'FD', 'Float': 'fd', 'Integer': 'bhil', 'UnsignedInteger': 'BHI'}
v = '#FFDAB9'