Open ALindblomA opened 3 years ago
This is the code I used when adding labels to a dendrogram where i can't see the timeseries beside, using the scipy.cluster.hierarchy:
`import scipy.cluster.hierarchy as hac
Z = hac.linkage(df.T, method='ward', metric='euclidean')
plt.figure(figsize=(5, 10))
plt.title('Hierarchical Clustering Dendrogram') plt.xlabel('distances') plt.ylabel('clusters')
hac.dendrogram(Z, orientation='left',truncate_mode='lastp', p=10, labels=df.columns)`
(10 was the number of time series i had here)
Adding the "label=df.columns" let me have the column headers as names, instead of have the number of the "position" my timeseries have in the df (I guess since i transpose the df when doing the clustering, it might be more correct to use the index (if not transposing)? But in my case i used the column headers).
Hi A suggestion/wish would be if there is a way to incorporate labels (based on for example the column headers) as an option when running the functions from the dendrogram-ts library ( instead of only getting the "positions")?
best regards Anna :)