This pages follows the chart #334 which explained how to build a basic dendrogram from hierarchical data with the ggraph library. Here, the goal is to present a few customization that can be applied to the dendrogram.

First of all, we need to load a few libraries and create a dummy dataset:


Circular or not?

First, of all, you can use a linear or a circular representation using the circular option. Note that a custom version of the circular dendrogram is available here.


Edge style

Then you can choose between different styles for your edges. Note that the usual ‘elbow’ representation is not implemented for hierarchical data yet.


Labels and points

You probably want to add labels to give more insight to your tree. And eventually nodes. This can be done using the geom_node_text and geom_node_point respectively. Note that the label addition is a bit more tricky for circular dendrogram, a solution is suggested in graph #339.



Custom aesthetics




It is a common task to add color or shapes to your dendrogram. It allows to show more clearly the organization of the dataset.

Ggraph works the same way as ggplot2 works. In the aesthetics part of each component, you can use a column of your initial data frame to be mapped to a shape, a color, a size or other..





Leave a Reply

Notify of