所以我使用以下命令在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中有没有办法做到这一点?
我发现以下函数(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)
}