-1
因此,我已使用下面的命令有什麼方法可以在R中的一組點上繪製邊界嗎?
plot(1, 1, xlim = c(min(al_comm$PC1),max(al_comm$PC1)), ylim = c(min(al_comm$PC2),max(al_comm$PC2)), type = 'n', xlab = '', ylab = '')
points(DW_PC1,DW_PC2,pch = 0, col = "red", cex = 1.1)
points(WW_PC1,WW_PC2,pch = 10, col = "blue", cex = 1.1)
points(DS_PC1,DS_PC2,pch = 5, col = "magenta", cex = 1.1)
現在我想通過繪製其周圍的線(或曲線)以封閉各三組的繪製三組數據的R中。在R中有沒有辦法做到這一點?
我發現以下功能(https://chitchatr.wordpress.com/2011/12/30/convex-hull-around-scatter-plot-in-r/),圍繞點繪製一條線。有沒有辦法讓它更平滑,更平滑?
Plot_ConvexHull<-function(xcoord, ycoord, lcolor){
hpts <- chull(x = xcoord, y = ycoord)
hpts <- c(hpts, hpts[1])
lines(xcoord[hpts], ycoord[hpts], col = lcolor)
}
看看'chull' – rawr
你見過這個? http://stackoverflow.com/questions/13577918/r-plotting-a-curve-around-a-set-of-points/13579969 – thelatemail
我剛剛添加了一個答案的鏈接問題。考慮關閉這個作爲愚蠢的... –