So I have plotted three groups of data in R using the following command
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)
Now I want to enclose each of these three groups by drawing a line (or a curve) around them. Is there a way to do that in R?
I found the following function (https://chitchatr.wordpress.com/2011/12/30/convex-hull-around-scatter-plot-in-r/) that draws a line around the points. Is there a way to offset it even more and make it more smooth?
Plot_ConvexHull<-function(xcoord, ycoord, lcolor){
hpts <- chull(x = xcoord, y = ycoord)
hpts <- c(hpts, hpts[1])
lines(xcoord[hpts], ycoord[hpts], col = lcolor)
}