You need to extract the leaf labels from the hierarchical clustering object and map them to the nodes. geom_node_text(aes(label = ifelse(leaf, label, NA)))
places labels only on leaf nodes by checking the leaf column.
library(ggraph)
library(tidygraph)
library(igraph)
# Perform hierarchical clustering
hcity.D2 <- hclust(UScitiesD, "ward.D2")
#plot(hcity.D2)
# Convert hclust object to a tidygraph
graph <- as_tbl_graph(hcity.D2)
# Create the circular dendrogram with labels for leaf nodes
ggraph(graph, layout = "dendrogram", circular = TRUE) +
geom_edge_link() +
geom_node_text(aes(label = ifelse(leaf, label, NA)), size = 3, repel = TRUE) +
coord_equal() +
theme_void()