Questions tagged [dendrogram]

A dendrogram (or tree diagram) is a graph used to represent relationships in hierarchical clustering.

Tag usage

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique.
Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

586 questions
6
votes
3 answers

How to color the branches and tick labels in the heatmap.2?

I have done a Heat Map using the function heatmap.2 of gplots in R, but I don't have an idea of how to coloring the branches and tick labels per groups (Eg. if I cut the tree to have four gruops like in my second figure). I have checked that it is…
Darwin PC
  • 871
  • 3
  • 23
  • 34
6
votes
1 answer

larger font and spacing between leaves in R dendrogram

I have a dendrogram in R that I just can't get it right. I'll show you what the problem is, please check this: http://img.photobucket.com/albums/v699/rica01/Rplot-1.png How can I make the labels on the leaves, bigger and more spaced between…
rica01
  • 69
  • 2
  • 6
6
votes
1 answer

Suppress leaf labels in dendrograms

I'm not an expert in cluster analysis and thus not really familiar with all the "special" contributed packages out there. Hence, I just used base routines as the did here for a quick example I was asked to produce. The problem is that my dataset has…
Rappster
  • 12,762
  • 7
  • 71
  • 120
6
votes
1 answer

python How to make a dendrogram from a dataframe

I am trying to find dendrogram a dataframe created using PANDAS package in python. An example data is shown below. import numpy as np from pandas import * import matplotlib.pyplot as plt from hcluster import pdist, linkage, dendrogram from…
Curious
  • 3,507
  • 8
  • 28
  • 30
5
votes
3 answers

Some questions on dendrogram - python (Scipy)

I am new to scipy but I managed to get the expected dendrogram. I am some more questions; In the dendrogram, distance between some points are 0 but its not visible due to image border. How can I remove the border and make the lower limit of y-axis…
Maggie
  • 5,923
  • 8
  • 41
  • 56
5
votes
3 answers

How to convert a tree to a dendrogram in R?

How can I convert a tree (which is the output of my Java program) to a dendrogram in R? Currently, I am converting the tree into the Newick format, using the suggestion given here. And then I use the ape package in R to read the Newick-formatted…
Burcu
  • 375
  • 2
  • 5
  • 9
5
votes
1 answer

Extract dendrogram from seaborn clustermap

Given the following example which is from: https://python-graph-gallery.com/404-dendrogram-with-heat-map/ It generates a dendrogram where I assume that it is based on scipy. # Libraries import seaborn as sns import pandas as pd from matplotlib…
Daniyal
  • 885
  • 3
  • 16
  • 28
5
votes
1 answer

How to convert a dendrogram to a tree object in python?

I'm trying to use the scipy.hierarchy.cluster module to hierarchically cluster some text. I've done the following: l = linkage(model.wv.syn0, method='complete', metric='cosine') den = dendrogram( l, leaf_rotation=0., leaf_font_size=16., …
5
votes
2 answers

Merging multiple hclust objects (or dendrograms)

Is there an easy way to merge multiple hclust objects (or dendrograms) at the root? I've made the example as complete as possible to illustrate my problem. Let's say I'd like to cluster USArrests by region and then unite all the hclust objects to…
csgroen
  • 2,511
  • 11
  • 28
5
votes
1 answer

How to line (cut) a dendrogram at the best K

How do I draw a line in a dendrogram that corresponds the best K for a given criteria? Like this: Lets suppose that this is my dendrogram, and the best K is 4. data("mtcars") myDend <- as.dendrogram(hclust(dist(mtcars))) plot(myDend) I know that…
Gilgamesh
  • 589
  • 1
  • 6
  • 20
5
votes
1 answer

Swap leafs of Python scipy's dendrogram/linkage

I generated a dendrogram plot for my dataset and I am not happy how the splits at some levels have been ordered. I am thus looking for a way to swap the two branches (or leaves) of a single split. If we look at the code and dendrogram plot at the…
dmeu
  • 3,842
  • 5
  • 27
  • 43
5
votes
3 answers

Stacked bar plot with hierarchical clustering (dendrogram)

I am trying to get something like this but unfortunately, I could not find any package that could enable me to plot stacked bar plot with dendrogram like the one shown below: Does anyone know how to do it?
Lu Pan
  • 51
  • 1
  • 3
5
votes
2 answers

Relation between dendrogram plot coordinates and ClusterNodes in scipy

I'm looking for a way to get the coordinates of a cluster point in the dendrogram plot based on its ClusterNode return by to_tree. Using scipy to build a dendogram from data such as: X = data Y = pdist(X) Z = linkage(Y) dend =…
sereizam
  • 2,048
  • 3
  • 20
  • 29
5
votes
1 answer

Interpreting the output of SciPy's hierarchical clustering dendrogram? (maybe found a bug...)

I am trying to figure out how the output of scipy.cluster.hierarchy.dendrogram works... I thought I knew how it worked and I was able to use the output to reconstruct the dendrogram but it seems as if I am not understanding it anymore or there is a…
O.rka
  • 29,847
  • 68
  • 194
  • 309
5
votes
1 answer

Rotate labels for ggplot dendrogram

I am trying to create a dendrogram using the package dendextend. It creates really nice gg dendrograms but unfortunately when you turn it into a "circle", the labels do not keep up. I'll provide an example below. My distance object is here:…
Brandon
  • 1,722
  • 1
  • 19
  • 32