【发布时间】:2016-02-25 18:29:28
【问题描述】:
我正在尝试创建漂亮的聚类点图形。是否有一个包可以在点的镶嵌之间创建分界链?理想情况下,它适合在ggplot 中绘图。
下面是一些示例代码:
#DivideLineExample
library(spatstat)
W=owin(c(0,1),c(0,1)) # Set up the Window
p<-runifpoint(42, win=W) # Get random points
ll=cbind(p$x,p$y) # get lat/long for each point
zclust=kmeans(ll,centers=4) # Cluster the points spatially into 4 clusters
K<-pp<-D<-list()
plot(W,main="Clustered Points")
for (i in 1:4){ # this breaks up the points into separate ppp objects for each cluster
K[[i]]=ll[zclust$cluster==i,]
pp[[i]]=as.ppp(K[[i]],W)
plot(pp[[i]],col=i,add=TRUE,cex=1.5,pch=16)
D[[i]]=dirichlet(pp[[i]]) # This performs the Dirichlet Tessellation and plots
plot(D[[i]],col=i,add=TRUE)
}
这样输出: http://imgur.com/CCXeOEB
我正在寻找的是: http://imgur.com/7nmtXjo
我知道一个算法exists。
有什么想法/选择吗?
【问题讨论】:
标签: r ggplot2 voronoi spatstat dirichlet