vuecore.dendrogram module#

class vuecore.dendrogram.Dendrogram(Z_dendrogram, orientation='bottom', hang=1, hide_labels=False, labels=None, colorscale=None, hovertext=None, color_threshold=None, width=inf, height=inf, xaxis='xaxis', yaxis='yaxis')[source]#

Bases: object

Refer to plot_dendrogram() for docstring.

get_color_dict(colorscale)[source]#

Returns colorscale used for dendrogram tree clusters.

Parameters:

colorscale (list) – colors to use for the plot in rgb format

Return (dict):

default colors mapped to the user colorscale

get_dendrogram_traces(Z_dendrogram, hang, colorscale, hovertext, color_threshold)[source]#

Calculates all the elements needed for plotting a dendrogram.

Parameters:
  • Z_dendrogram (ndarray) – Matrix of observations as array of arrays

  • hang (float) – dendrogram distance of leaf lines

  • colorscale (list) – Color scale for dendrogram tree clusters

  • hovertext (list) – List of hovertext for constituent traces of dendrogram

Return (tuple):

Contains all the traces in the following order:

  1. trace_list: List of Plotly trace objects for dendrogram tree

  2. icoord: All X points of the dendrogram tree as array of arrays with length 4

  3. dcoord: All Y points of the dendrogram tree as array of arrays with length 4

  4. ordered_labels: leaf labels in the order they are going to appear on the plot

  5. Z_dendrogram[‘leaves’]: left-to-right traversal of the leaves

set_axis_layout(axis_key, hide_labels)[source]#

Sets and returns default axis object for dendrogram figure.

Parameters:

axis_key (str) – E.g., ‘xaxis’, ‘xaxis1’, ‘yaxis’, yaxis1’, etc.

Return (dict):

An axis_key dictionary with set parameters.

set_figure_layout(width, height, hide_labels)[source]#

Sets and returns default layout object for dendrogram figure.

Parameters:
  • width (int) – plot width

  • height (int) – plot height

  • hide_labels (boolean) – show leaf labels

Returns:

Plotly layout

vuecore.dendrogram.plot_dendrogram(Z_dendrogram, cutoff_line=True, value=15, orientation='bottom', hang=30, hide_labels=False, labels=None, colorscale=None, hovertext=None, color_threshold=None)[source]#

Modified version of Plotly _dendrogram.py that returns a dendrogram Plotly figure object with cutoff line.

Parameters:
  • Z_dendrogram (ndarray) – Matrix of observations as array of arrays

  • cutoff_line (boolean) – plot distance cutoff line

  • value (float or int) – dendrogram distance for cutoff line

  • orientation (str) – ‘top’, ‘right’, ‘bottom’, or ‘left’

  • hang (float) – dendrogram distance of leaf lines

  • hide_labels (boolean) – show leaf labels

  • labels (list) – List of axis category labels(observation labels)

  • colorscale (list) – Optional colorscale for dendrogram tree

  • hovertext (list[list]) – List of hovertext for constituent traces of dendrogram clusters

  • color_threshold (double) – Value at which the separation of clusters will be made

Returns:

Plotly figure object

Example:

figure = plot_dendrogram(dendro_tree, hang=0.9, cutoff_line=False)