pytools.viz.dendrogram.base.DendrogramStyle#

class pytools.viz.dendrogram.base.DendrogramStyle[source]#

Base class for dendrogram drawing styles.

Bases

DrawingStyle

Metaclasses

ABCMeta

Method summary

draw_leaf_labels

Render the labels for all leaves.

draw_link_connector

Draw a connector between two sub-trees and their parent node.

draw_link_leg

Draw a "leg" connecting two levels of the linkage tree hierarchy.

finalize_drawing

Finalize the dendrogram, adding labels to the axes.

get_default_style_name

Get the name of the default style associated with this style class.

get_named_styles

Get a mapping of names to default instances of this style class.

start_drawing

Prepare a new dendrogram for drawing, using the given title.

Definitions

abstract draw_leaf_labels(*, names, weights)[source]#

Render the labels for all leaves.

Parameters
Return type

None

Draw a connector between two sub-trees and their parent node.

Parameters
  • bottom (float) – the height (i.e. cluster distance) of the sub-trees

  • top (float) – the height of the parent node

  • first_leaf (int) – the index of the first leaf in the left sub-tree

  • n_leaves_left (int) – the number of leaves in the left sub-tree

  • n_leaves_right (int) – the number of leaves in the right sub-tree

  • weight (float) – the weight of the parent node

  • weight_cumulative (float) – the cumulative weight of all nodes with a lower position index than the current one

  • tree_height (float) – the total height of the linkage tree

Return type

None

Draw a “leg” connecting two levels of the linkage tree hierarchy.

Parameters
  • bottom (float) – the height of the child node in the linkage tree

  • top (float) – the height of the parent node in the linkage tree

  • leaf (float) – the index of the leaf where the link leg should be drawn (may be a float, indicating a position in between two leaves)

  • weight (float) – the weight of the child node

  • weight_cumulative (float) – the cumulative weight of all nodes with a lower position index than the current one

  • tree_height (float) – the total height of the linkage tree

Return type

None

finalize_drawing(*, leaf_label=None, distance_label=None, weight_label=None, max_distance=None, leaf_names=None, **kwargs)[source]#

Finalize the dendrogram, adding labels to the axes.

Parameters
  • leaf_label (Optional[str]) – the label for the leaf axis

  • distance_label (Optional[str]) – the label for the distance axis

  • weight_label (Optional[str]) – the label for the weight scale

  • max_distance (Optional[float]) – the height (= maximum possible distance) of the dendrogram

  • leaf_names (Optional[Sequence[str]]) – the names of the dendrogram leaf nodes

  • kwargs (Any) – additional drawer-specific arguments

Return type

None

abstract classmethod get_default_style_name()#

Get the name of the default style associated with this style class.

The default style is obtained by instantiating this style class without parameters.

Common examples for default style names are matplot and text.

Return type

str

Returns

the name of the default style

classmethod get_named_styles()#

Get a mapping of names to default instances of this style class.

Return type

dict[str, Callable[..., DendrogramStyle]]

Returns

a dictionary mapping of names to default instances of this style class

start_drawing(*, title, leaf_label=None, distance_label=None, weight_label=None, max_distance=None, leaf_names=None, **kwargs)[source]#

Prepare a new dendrogram for drawing, using the given title.

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

  • leaf_label (Optional[str]) – the label for the leaf axis

  • distance_label (Optional[str]) – the label for the distance axis

  • weight_label (Optional[str]) – the label for the weight scale

  • max_distance (Optional[float]) – the height (= maximum possible distance) of the dendrogram

  • leaf_names (Optional[Sequence[str]]) – the names of the dendrogram leaf nodes

  • kwargs (Any) – additional drawer-specific arguments

Return type

None