# plotg par Michel BAYLAC, Museum national d'Histoire naturelle, UMR CNRS 5202 OSEB # 06/05/2008 plotg <- function(mat,cols=c(1,2),groupe,pchull=TRUE,llocate=TRUE,lcex=1.2, titre = " ", aspr = 1) { groupe <- as.factor(groupe) groupn <- unique(groupe) groupc <- as.numeric(groupn) col1 <- cols[1] col2 <- cols[2] matc <- mat[,c(col1, col2)] xlbl <- paste("Axis",col1,sep = " ") ylbl <- paste("Axis",col2,sep = " ") lim1 <- range(matc[,1]) lim2 <- range(matc[,2]) plot(matc[,1],matc[,2],xlim=lim1,ylim=lim2, col=as.numeric(groupe),pch=20,xlab=xlbl,ylab=ylbl,cex=1.5, asp=aspr, main = titre) if (pchull == TRUE) { for(i in 1:length(groupn)) { gp <- matc[which(groupe == groupn[i]),] if(ncol(as.matrix(gp)) > 1) { gpc <- gp[chull(gp),] gpc <- rbind(gpc, gpc[1,]) lines(gpc[,1],gpc[,2],col=groupc[i],lty=1,lwd=1.5) } } } if (llocate == TRUE) { print("positionner la souris à l\'emplacement du coin supérieur gauche de la boîte légende") print(" ... puis cliquer 1 seule fois avec le BOUTON GAUCHE") lloc <- locator(1) legend(lloc$x,lloc$y,as.vector(groupn),col=groupc,bty="n",pch=20, cex=lcex) } }