I am trying to generate some silhouette with a R library called "factoextra". Unfortunately, I end up in a problem. Let's look at the following example with the "iris" dataset.
library(factoextra)
library(cluster)
set.seed(123)
data("iris")
iris.scaled <- scale(iris[, -5])
# K-means clustering
km.res <- kmeans(iris.scaled, 3, nstart = 2)
# Visualize silhouhette information
sil <- silhouette(km.res$cluster, dist(iris.scaled))
fviz_silhouette(sil)+
scale_fill_discrete(labels=c("a","b","c"))
I tried to add a specific legend "a","b","c".
As you can see the legend duplicate, showing "a","b","c" and then "1","2","3". Is there a way to show only "a","b","c"?