我想向我的集群添加 Voronoi 图。也就是说,我想要一张包含我的簇、质心 + Voronoi 区域的图。有简单的方法吗?
I tried:
x<-c(4,7,9,2,3,3,7,7,8,8,9,9)
y<-c(6,3,3,6,5,7,2,9,4,9,2,8)
mat<-cbind(x,y)# defining matrix
Kmeans<-kmeans(mat,centers=3) # with 3 centroids
plot(x,y,col=Kmeans$cluster,pch=19,cex=2)
points(Kmeans$centers,col=1:3,pch=3,cex=3,lwd=3)
library(tripack)
test<-voronoi.mosaic(x,y)
plot(x,y,col=Kmeans$cluster,pch=19,cex=2)
plot(test)
在这里我只是不知道如何将它们结合起来产生合理的情节。