class RainbowPalette(Palette):
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.
Method | __init__ |
Creates a rainbow palette. |
Method | _get |
Returns the color corresponding to the given color index. |
Instance Variable | _alpha |
Undocumented |
Instance Variable | _dh |
Undocumented |
Instance Variable | _s |
Undocumented |
Instance Variable | _start |
Undocumented |
Instance Variable | _v |
Undocumented |
Inherited from Palette
:
Method | __len__ |
Returns the number of colors in this palette |
Method | __plot__ |
Plots the colors of the palette on the given Cairo context |
Method | __repr__ |
Undocumented |
Method | clear |
Clears the result cache. |
Method | get |
Returns the given color from the palette. |
Method | get |
Returns multiple colors from the palette. |
Property | length |
Returns the number of colors in this palette |
Instance Variable | _cache |
Undocumented |
Instance Variable | _length |
Undocumented |
igraph.drawing.colors.Palette.__init__
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. |
igraph.drawing.colors.Palette._get
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 |