I can't see the result of silhouette plot except for the axis(in R)
Asked Answered
P

2

6

everyone. I have a problem in plotting silhouette chart in R.

It is my code.

#k-means clustering
#install.packages("cluster")
library(cluster)
kc <- kmeans(nsoap, centers=3)

dissE <- daisy(nsoap)
sk <- silhouette(kc$cl,dissE)

plot(sk)
dev.off()

I just got this result. It is without the contents...

enter image description here

How can I overcome this problem?

Thank you:)

Panda answered 10/10, 2015 at 14:15 Comment(1)
Possible duplicate of Make silhouette plot legible for k-meansMyriapod
G
9

Posting answer as this was the top result for a google search on this problem.

This is an issue with how the plot is rendered in RStudio.

This post (https://mcmap.net/q/1146412/-make-silhouette-plot-legible-for-k-means) shows how to set border = NA in the call to plot() to cause the plot to render correctly.

Another option used here (https://mcmap.net/q/1075471/-silhouette-plot-in-r) is to call windows() in RStudio to get a separate window for graphics that plots the Silhouette Coefficients correctly without using the border= option.

Gwenngwenneth answered 29/4, 2018 at 17:47 Comment(1)
Only the second option works when trying to plot the banner plot of agnes() with plot(..., which.plots=1).Corpuscle
M
-1

Try it with the argument col = "darkblue". For example:

plot(sk, col="darkblue")

and then you will see the plot in light color if you focus your sigth.

Mingy answered 1/12, 2015 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.