python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Package drawing :: Module colors :: Class RainbowPalette
[hide private]

Class RainbowPalette

source code

object --+    
         |    
   Palette --+
             |
            RainbowPalette

A palette that varies the hue of the colors along a scale.

Colors in a rainbow palette all have the same saturation, value and alpha components, while the hue is varied between two given extremes linearly. This palette has the advantage that it wraps around nicely if the hue is varied between zero and one (which is the default).

Example:

>>> pal = RainbowPalette(n=120)
>>> pal.get(0)
(1.0, 0.0, 0.0, 1.0)
>>> pal.get(20)
(1.0, 1.0, 0.0, 1.0)
>>> pal.get(40)
(0.0, 1.0, 0.0, 1.0)
>>> pal = RainbowPalette(n=120, s=1, v=0.5, alpha=0.75)
>>> pal.get(60)
(0.0, 0.5, 0.5, 0.75)
>>> pal.get(80)
(0.0, 0.0, 0.5, 0.75)
>>> pal.get(100)
(0.5, 0.0, 0.5, 0.75)
>>> pal = RainbowPalette(n=120)
>>> pal2 = RainbowPalette(n=120, start=0.5, end=0.5)
>>> pal.get(60) == pal2.get(0)
True
>>> pal.get(90) == pal2.get(30)
True

This palette was modeled after the rainbow command of R.

Instance Methods [hide private]
 
__init__(self, n=256, s=1, v=1, start=0, end=1, alpha=1)
Creates a rainbow palette.
source code
 
_get(self, v)
Returns the color corresponding to the given color index.
source code

Inherited from Palette: __getitem__, __len__, __plot__, __repr__, clear_cache, get, get_many

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from Palette: length

Inherited from object: __class__

Method Details [hide private]

__init__(self, n=256, s=1, v=1, start=0, end=1, alpha=1)
(Constructor)

source code 

Creates a rainbow palette.

Parameters:
  • n - the number of colors in the palette.
  • s - the saturation of the colors in the palette.
  • v - the value component of the colors in the palette.
  • start - the hue at which the rainbow begins (between 0 and 1).
  • end - the hue at which the rainbow ends (between 0 and 1).
  • alpha - the alpha component of the colors in the palette.
Overrides: object.__init__

_get(self, v)

source code 

Returns the color corresponding to the given color index.

Parameters:
  • v - numerical index of the color to be retrieved
Returns:
a 4-tuple containing the RGBA values
Overrides: Palette._get

   Home       Trees       Indices       Help