plotly.figure_factory.create_dendrogram

plotly.figure_factory.create_dendrogram(X, orientation='bottom', labels=None, colorscale=None, distfun=None, linkagefun=<function <lambda>>, hovertext=None, color_threshold=None)

Function that returns a dendrogram Plotly figure object.

See also https://dash.plot.ly/dash-bio/clustergram.

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

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

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

  • colorscale ((list)) – Optional colorscale for dendrogram tree

  • distfun ((function)) – Function to compute the pairwise distance from the observations

  • linkagefun ((function)) – Function to compute the linkage matrix from the pairwise distances

  • 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

Example 1: Simple bottom oriented dendrogram

>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np
>>> X = np.random.rand(10,10)
>>> fig = create_dendrogram(X)
>>> fig.show()

Example 2: Dendrogram to put on the left of the heatmap

>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np
>>> X = np.random.rand(5,5)
>>> names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark']
>>> dendro = create_dendrogram(X, orientation='right', labels=names)
>>> dendro.update_layout({'width':700, 'height':500}) 
>>> dendro.show()

Example 3: Dendrogram with Pandas

>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np
>>> import pandas as pd
>>> Index= ['A','B','C','D','E','F','G','H','I','J']
>>> df = pd.DataFrame(abs(np.random.randn(10, 10)), index=Index)
>>> fig = create_dendrogram(df, labels=Index)
>>> fig.show()