pytools.viz.dendrogram.DendrogramDrawer#

class pytools.viz.dendrogram.DendrogramDrawer(style=None)[source]#

Draws dendrogram representations of LinkageTree objects.

Bases

Drawer [LinkageTree, DendrogramStyle]

Metaclasses

ABCMeta

Parameters

style (Union[DendrogramStyle, str, None]) – the style to be used for drawing; either as a DrawingStyle instance, or as the name of a named style supported by this drawer type; if not specified, the default style will be used as returned by get_default_style()

Method summary

draw

Render the data using the style associated with this drawer.

get_default_style

Get the default style for this drawer.

get_named_styles

Get a mapping of names to style factories for all named styles recognized by this drawer's initializer.

get_style

Get a style object by name.

get_style_classes

Get all style classes available for this drawer type.

get_style_kwargs

Using the given data object, derive keyword arguments to be passed to the style's start_drawing() and finalize_drawing() methods.

Attribute summary

style

The DrawingStyle used by this drawer.

Definitions

_draw(data)[source]#

Core drawing method invoked my method draw().

Must be implemented by subclasses of Drawer.

Parameters

data (LinkageTree) – the data to be rendered

Return type

None

draw(data, *, title)#

Render the data using the style associated with this drawer.

Creates a thread-safe lock on this drawer, then calls the following methods in sequence:

  1. Method start_drawing() of this drawer’s style attribute, passing the title and additional keyword arguments obtained from this drawer’s get_style_kwargs()

  2. Method _draw(), passing along the data argument

  3. Method finalize_drawing() of this drawer’s style attribute, passing the keyword arguments obtained from this drawer’s get_style_kwargs()

Parameters
  • data (DendrogramDrawer) – the data to be rendered

  • title (str) – the title of the resulting chart

Return type

None

classmethod get_default_style()[source]#

Get the default style for this drawer.

Return type

DendrogramStyle

Returns

the default style for this drawer

classmethod get_named_styles()#

Get a mapping of names to style factories for all named styles recognized by this drawer’s initializer.

A factory is a class or function with no mandatory parameters.

Return type

AbstractSet[str]

classmethod get_style(name)#

Get a style object by name.

Parameters

name (str) – the name of the style

Return type

DendrogramStyle

Returns

the style object

Raises

KeyError – if the style name is not recognized

classmethod get_style_classes()[source]#

Get all style classes available for this drawer type.

Return type

Iterable[type[DendrogramStyle]]

Returns

an iterable of style classes

get_style_kwargs(data)[source]#

Using the given data object, derive keyword arguments to be passed to the style’s start_drawing() and finalize_drawing() methods.

Parameters

data (LinkageTree) – the data to be rendered

Return type

dict[str, Any]

Returns

the style attributes for the given data object