I am hoping to accomplish two things.
I want to be able to rotate the labels. The
fviz_dend
function is compatible withggplot2
theme
function but I am not entirely sure how to accomplish it.I would like to change the line colour of the dendrogram - specifically those that do not fall within the clustering. I would like to change the black to white.
Any idea how to accomplish it on this reprex?
df <- scale(mtcars) # Standardize the data
library("factoextra")
library("cluster")
dist <- dist(df, method = "euclidean") # df = standardized data
hc <- hclust(dist, method = "ward.D2")
fviz_dend(hc, k = 4, # Cut in four groups
cex = 0.6, # label size
k_colors = "lancet",
color_labels_by_k = TRUE, # color labels by groups
rect = TRUE, # Add rectangle around groups
rect_border = "lancet",
rect_fill = TRUE,
rotate = TRUE)
ggplot2::theme_dark()
#> Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
#> "none")` instead.