Skip to content

Commit 1d9c62c

Browse files
committed
update docstring
1 parent b7edba4 commit 1d9c62c

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

packages/python/plotly/plotly/figure_factory/_dendrogram.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,59 +21,63 @@ def create_dendrogram(
2121
color_threshold=None,
2222
):
2323
"""
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-
24+
Create a dendrogram Plotly figure object.
25+
26+
This function is a thin wrapper around `scipy.cluster.hierarchy.dendrogram`.
27+
28+
Parameters
29+
----------
30+
X : ndarray
31+
Matrix of observations as array of arrays.
32+
orientation : str
33+
'top', 'right', 'bottom', or 'left'. Default is 'bottom'.
34+
labels : list
35+
List of axis category labels (observation labels).
36+
colorscale : list
37+
Optional colorscale for the dendrogram tree. Requires 8 colors to be specified,
38+
the 7th of which is ignored. With scipy>=1.5.0, the 2nd, 3rd, and 6th are used
39+
twice as often as the others. Given a shorter list, the missing values are replaced
40+
with defaults and with a longer list the extra values are ignored.
41+
distfun : function
42+
Function to compute the pairwise distance from the observations.
43+
linkagefun : function
44+
Function to compute the linkage matrix from the pairwise distances.
45+
hovertext : list of list
46+
List of hovertext for constituent traces of dendrogram clusters.
47+
color_threshold : float
48+
Value at which the separation of clusters will be made.
49+
50+
Returns
51+
-------
52+
plotly.graph_objs._figure.Figure
53+
A Plotly figure object representing the dendrogram.
54+
55+
Examples
56+
--------
4757
Example 1: Simple bottom oriented dendrogram
4858
4959
>>> from plotly.figure_factory import create_dendrogram
50-
5160
>>> import numpy as np
52-
53-
>>> X = np.random.rand(10,10)
61+
>>> X = np.random.rand(10, 10)
5462
>>> fig = create_dendrogram(X)
5563
>>> fig.show()
5664
5765
Example 2: Dendrogram to put on the left of the heatmap
5866
5967
>>> from plotly.figure_factory import create_dendrogram
60-
6168
>>> import numpy as np
62-
63-
>>> X = np.random.rand(5,5)
69+
>>> X = np.random.rand(5, 5)
6470
>>> names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark']
6571
>>> dendro = create_dendrogram(X, orientation='right', labels=names)
66-
>>> dendro.update_layout({'width':700, 'height':500}) # doctest: +SKIP
72+
>>> dendro.update_layout({'width': 700, 'height': 500}) # doctest: +SKIP
6773
>>> dendro.show()
6874
6975
Example 3: Dendrogram with Pandas
7076
7177
>>> from plotly.figure_factory import create_dendrogram
72-
7378
>>> import numpy as np
7479
>>> import pandas as pd
75-
76-
>>> Index= ['A','B','C','D','E','F','G','H','I','J']
80+
>>> Index = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
7781
>>> df = pd.DataFrame(abs(np.random.randn(10, 10)), index=Index)
7882
>>> fig = create_dendrogram(df, labels=Index)
7983
>>> fig.show()

0 commit comments

Comments
 (0)