Dendrogram utils
Functions¶
create_dendrogram(x, add_sep, nb_clusters, orientation='bottom', labels=None, colorscale=None, hovertext=None)
¶
Return a dendrogram Plotly figure object. This is a thin wrapper around scipy.cluster.hierarchy.dendrogram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Result of scipy.cluster.hierarchy.linkage() function |
required |
add_sep
|
bool
|
Whether a separation is shown on the TAK or no. This parameter allows the dendogram to be cut and only displays clusters on the dendogram |
required |
nb_clusters
|
int
|
Number of clusters on the TAK |
required |
orientation
|
str
|
'top', 'right', 'bottom', or 'left' |
'bottom'
|
labels
|
list[str] | None
|
List of axis category labels(observation labels) |
None
|
colorscale
|
list | None
|
Optional colorscale for the dendrogram tree. Requires 8 colors to be specified, the 7th of which is ignored. With scipy>=1.5.0, the 2nd, 3rd and 6th are used twice as often as the others. Given a shorter list, the missing values are replaced with defaults and with a longer list the extra values are ignored. |
None
|
hovertext
|
list | None
|
List of hovertext for constituent traces of dendrogram clusters |
None
|
Returns:
Type | Description |
---|---|
tuple[Figure, list[float], float]
|
Dendogram representing the hiearchical clustering |
Source code in opentak/dendrogram_utils.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|