Package Bio :: Package Phylo :: Module BaseTree :: Class BranchColor
[hide private]
[frames] | no frames]

Class BranchColor

source code

object --+
         |
        BranchColor
Known Subclasses:

Indicates the color of a clade when rendered graphically.

The color should be interpreted by client code (e.g. visualization programs) as applying to the whole clade, unless overwritten by the color(s) of sub-clades.

Color values must be integers from 0 to 255.

Instance Methods [hide private]
 
__init__(self, red, green, blue)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
to_hex(self)
Return a 24-bit hexadecimal RGB representation of this color.
source code
 
to_rgb(self)
Return a tuple of RGB values (0 to 255) representing this color.
source code
 
__repr__(self)
Preserve the standard RGB order when representing this object.
source code
 
__str__(self)
Show the color's RGB values.
source code

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

Class Methods [hide private]
 
from_hex(cls, hexstr)
Construct a BranchColor object from a hexadecimal string.
source code
 
from_name(cls, colorname)
Construct a BranchColor object by the color's name.
source code
Class Variables [hide private]
  color_names = {'aqua': (0, 255, 255), 'b': (0, 0, 255), 'black...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, red, green, blue)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

from_hex(cls, hexstr)
Class Method

source code 

Construct a BranchColor object from a hexadecimal string.

The string format is the same style used in HTML and CSS, such as '#FF8000' for an RGB value of (255, 128, 0).

to_hex(self)

source code 

Return a 24-bit hexadecimal RGB representation of this color.

The returned string is suitable for use in HTML/CSS, as a color parameter in matplotlib, and perhaps other situations.

Example:

>>> bc = BranchColor(12, 200, 100)
>>> bc.to_hex()
'#0cc864'

to_rgb(self)

source code 

Return a tuple of RGB values (0 to 255) representing this color.

Example:

>>> bc = BranchColor(255, 165, 0)
>>> bc.to_rgb()
(255, 165, 0)

__repr__(self)
(Representation operator)

source code 
Preserve the standard RGB order when representing this object.
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 
Show the color's RGB values.
Overrides: object.__str__

Class Variable Details [hide private]

color_names

Value:
{'aqua': (0, 255, 255),
 'b': (0, 0, 255),
 'black': (0, 0, 0),
 'blue': (0, 0, 255),
 'brown': (165, 42, 42),
 'c': (0, 255, 255),
 'cyan': (0, 255, 255),
 'fuchsia': (255, 0, 255),
...