MCPcopy Index your code
hub / github.com/plotly/plotly.py / create_dendrogram

Function create_dendrogram

plotly/figure_factory/_dendrogram.py:13–105  ·  view source on GitHub ↗

Function that returns a dendrogram Plotly figure object. This is a thin wrapper around scipy.cluster.hierarchy.dendrogram. See also https://dash.plot.ly/dash-bio/clustergram. :param (ndarray) X: Matrix of observations as array of arrays :param (str) orientation: 'top', 'right'

(
    X,
    orientation="bottom",
    labels=None,
    colorscale=None,
    distfun=None,
    linkagefun=lambda x: sch.linkage(x, "complete"),
    hovertext=None,
    color_threshold=None,
)

Source from the content-addressed store, hash-verified

11
12
13def create_dendrogram(
14 X,
15 orientation="bottom",
16 labels=None,
17 colorscale=None,
18 distfun=None,
19 linkagefun=lambda x: sch.linkage(x, "complete"),
20 hovertext=None,
21 color_threshold=None,
22):
23 """
24 Function that returns a dendrogram Plotly figure object. This is a thin
25 wrapper around scipy.cluster.hierarchy.dendrogram.
26
27 See also https://dash.plot.ly/dash-bio/clustergram.
28
29 :param (ndarray) X: Matrix of observations as array of arrays
30 :param (str) orientation: 'top', 'right', 'bottom', or 'left'
31 :param (list) labels: List of axis category labels(observation labels)
32 :param (list) colorscale: Optional colorscale for the dendrogram tree.
33 Requires 8 colors to be specified, the 7th of
34 which is ignored. With scipy>=1.5.0, the 2nd, 3rd
35 and 6th are used twice as often as the others.
36 Given a shorter list, the missing values are
37 replaced with defaults and with a longer list the
38 extra values are ignored.
39 :param (function) distfun: Function to compute the pairwise distance from
40 the observations
41 :param (function) linkagefun: Function to compute the linkage matrix from
42 the pairwise distances
43 :param (list[list]) hovertext: List of hovertext for constituent traces of dendrogram
44 clusters
45 :param (double) color_threshold: Value at which the separation of clusters will be made
46
47 Example 1: Simple bottom oriented dendrogram
48
49 >>> from plotly.figure_factory import create_dendrogram
50
51 >>> import numpy as np
52
53 >>> X = np.random.rand(10,10)
54 >>> fig = create_dendrogram(X)
55 >>> fig.show()
56
57 Example 2: Dendrogram to put on the left of the heatmap
58
59 >>> from plotly.figure_factory import create_dendrogram
60
61 >>> import numpy as np
62
63 >>> X = np.random.rand(5,5)
64 >>> names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark']
65 >>> dendro = create_dendrogram(X, orientation='right', labels=names)
66 >>> dendro.update_layout({'width':700, 'height':500}) # doctest: +SKIP
67 >>> dendro.show()
68
69 Example 3: Dendrogram with Pandas
70

Callers 1

create_dendrogramMethod · 0.90

Calls 1

_DendrogramClass · 0.85

Tested by

no test coverage detected