python-igraph API reference

List of all classes, functions and methods in python-igraph

class documentation

Base class of color palettes.

Color palettes are mappings that assign integers from the range 0..n-1 to colors (4-tuples). n is called the size or length of the palette. igraph comes with a number of predefined palettes, so this class is useful for you only if you want to define your own palette. This can be done by subclassing this class and implementing the Palette._get method as necessary.

Palettes can also be used as lists or dicts, for the __getitem__ method is overridden properly to call Palette.get.

Method __init__ Undocumented
Method clear_cache Clears the result cache.
Method get Returns the given color from the palette.
Method get_many Returns multiple colors from the palette.
Property length Returns the number of colors in this 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
Instance Variable _length Undocumented
Instance Variable _cache Undocumented
Method _get Override this method in a subclass to create a custom palette.
_length =

Undocumented

_cache =

Undocumented

(type: dict)
def clear_cache(self):

Clears the result cache.

The return values of Palette.get are cached. Use this method to clear the cache.

def get(self, v):

Returns the given color from the palette.

Values are cached: if the specific value given has already been looked up, its value will be returned from the cache instead of calculating it again. Use Palette.clear_cache to clear the cache if necessary.

Parametersvthe color to be retrieved. If it is an integer, it is passed to Palette._get to be translated to an RGBA quadruplet. Otherwise it is passed to color_name_to_rgb() to determine the RGBA values.
Returnsthe color as an RGBA quadruplet
Noteyou shouldn't override this method in subclasses, override _get instead. If you override this method, lookups in the known_colors dict won't work, so you won't be able to refer to colors by names or RGBA quadruplets, only by integer indices. The caching functionality will disappear as well. However, feel free to override this method if this is exactly the behaviour you want.
def get_many(self, colors):

Returns multiple colors from the palette.

Values are cached: if the specific value given has already been looked upon, its value will be returned from the cache instead of calculating it again. Use Palette.clear_cache to clear the cache if necessary.

Parameterscolorsthe list of colors to be retrieved. The palette class tries to make an educated guess here: if it is not possible to interpret the value you passed here as a list of colors, the class will simply try to interpret it as a single color by forwarding the value to Palette.get.
Returnsthe colors as a list of RGBA quadruplets. The result will be a list even if you passed a single color index or color name.
def _get(self, v):

Override this method in a subclass to create a custom palette.

You can safely assume that v is an integer in the range 0..n-1 where n is the size of the palette.

Parametersvnumerical index of the color to be retrieved
Returnsa 4-tuple containing the RGBA values
@property
length =

Returns the number of colors in this palette

def __len__(self):

Returns the number of colors in this palette

def __plot__(self, context, bbox, palette, *args, **kwds):

Plots the colors of the palette on the given Cairo context

Supported keyword arguments are:

  • border_width: line width of the border shown around the palette. If zero or negative, the border is turned off. Default is 1.
  • grid_width: line width of the grid that separates palette cells. If zero or negative, the grid is turned off. The grid is also turned off if the size of a cell is less than three times the given line width. Default is 0. Fractional widths are also allowed.
  • orientation: the orientation of the palette. Must be one of the following values: left-right, bottom-top, right-left or top-bottom. Possible aliases: horizontal = left-right, vertical = bottom-top, lr = left-right, rl = right-left, tb = top-bottom, bt = bottom-top. The default is left-right.
def __repr__(self):

Undocumented

API Documentation for igraph, generated by pydoctor 21.2.2.