Biskit :: ColorSpectrum :: ColorSpectrum :: Class ColorSpectrum
[hide private]
[frames] | no frames]

Class ColorSpectrum

source code

Translate a range of numeric values into a range of color codes.

Example:
>>> p = ColorSpectrum( 'grey', 1, 500 )
>>> single_color= p.color( 250 )
>>> color_range = p.colors( range(25,250), resetLimits=0 )
Available palettes are: * grey * plasma * plasma2 (default) * sausage (seems to have a discontinuity at 50%, see example below)

Instance Methods [hide private]
  __init__(self, palette="plasma2", vmin=0., vmax=1.)
Create a new palette of given type and value range.
int __make_col(self, red, green, blue)
Create color.
int __normalize(self, value)
Normalize values
int color(self, value)
Translate a single value into a color.
[int] colors(self, values, resetLimits=1)
Translate a list of values into a list of colors.
array of float color_array(self, a, resetLimits=1)
Returns matrix of color codes with same dimensions as a
[ (float,int) ], value legend(self)
Returns color mapping for each color
  __map(self, x)
  __grey(self, x)
  __plasma2(self, x)
  __plasma(self, x)
  __sausage(self, x)

Class Variables [hide private]
  MAX_COL = {'grey': 3* 255, 'plasma': 3* 255, 'plasma2': 3* 255...

Method Details [hide private]

__init__(self, palette="plasma2", vmin=0., vmax=1.)
(Constructor)

source code 

Create a new palette of given type and value range.
Parameters:
  • palette (str) - palette type (grey, sausage, plasma, plasma2) (default: plasma2)
  • vmin (float) - smallest value covered by the color range (default: 0.)
  • vmax (float) - largest value covered by the color range (default: 1.)
Raises:

__make_col(self, red, green, blue)

source code 

Create color.
Parameters:
  • red (int) - rgb color, 0-255
  • green (int) - rgb color, 0-255
  • blue (int) - rgb color, 0-255
Returns: int
color

__normalize(self, value)

source code 

Normalize values
Parameters:
  • value (float) - normalization value
Returns: int
normalized color

color(self, value)

source code 

Translate a single value into a color.
Parameters:
  • value (float) - value to be translated into color
Returns: int
color code for value

colors(self, values, resetLimits=1)

source code 

Translate a list of values into a list of colors.
Parameters:
  • values ([float]) - values to be translated into colors
  • resetLimits (1|0) - re-define color range on max and min of values (default: 1)
Returns: [int]
color codes

color_array(self, a, resetLimits=1)

source code 
Parameters:
  • a (array of float) - array of float
  • resetLimits (1|0) - re-define color range on max and min of values (default: 1)
Returns: array of float
matrix of color codes with same dimensions as a

legend(self)

source code 
Returns: [ (float,int) ], value
color mapping for each color

__map(self, x)

source code 

__grey(self, x)

source code 

__plasma2(self, x)

source code 

__plasma(self, x)

source code 

__sausage(self, x)

source code 

Class Variable Details [hide private]

MAX_COL

Value:
{'grey': 3* 255, 'plasma': 3* 255, 'plasma2': 3* 255, 'sausage': 2* 25
5}