![]() |
VOOZH | about |
In this article, we are going to see how to customize dendrogram. It is also known as a tree diagram and it is a visual representation of the hierarchical relationship between items. A dendrogram's main purpose is to figure out the best approach to assign objects to clusters.
To create a dendrogram we will igraph package which is used for creating and manipulating graphs and analyzing networks graph. So for creating a dendrogram, we will create a dataframe into the hierarchical data structure and then transform it into an edge list. To plot a Dendrogram we will use the following syntax:
ggraph(dataset, layout)
Parameters:
- Dataframe: Hierarchical dataset/vector
- layout: Dimension of layout
- Circular: True/False
Syntax to install and import igraph package in the R working console:
install.package('igraph')
library(igraph)
There are some optional functions to create edge into diagonal we will use geom_edge_diagonal() methods and to add nodes into a graph we will use geom_node_point() methods.
Output:
To create a circular layout we will use circular = True, which will plot it into the circular layout.
Output:
To make the straight edge dendrogram we will use geom_edge_diagonal() methods.
Output:
To add the labels into the dendrogram we will use geom_node_text() which will add the labels into the graph into a hierarchical structure
Output:
To Customize Labels in Dendrogram we use geom_node_text() which will add the labels along with color into the graph into the hierarchical structure
Output:
To Customize Labels in Dendrogram we use geom_node_point() which will add the nodes along with color into the graph into a hierarchical structure
Output: