Nous allons donner des exemples de codes permettant de créer et de sauvegarder des images de repères, contenant, des points, des segments, des vecteurs, des polygones.
Point dans un repère

library(latex2exp) ############################################# # debut image # png( "geo_point.png", width = 500, height = 500 ) #------ début du repere a=-6 b=6 plot(0,0, xlim=c(a,b), ylim=c(a,b), xaxs="i", yaxs="i", asp=1, axes=FALSE, xaxp=c(a,b,b-a), yaxp=c(a,b,b-a), panel.first = grid(nx=b-a,ny=b-a), xlab=NA, ylab=NA, type="l", lwd=2, col="red") axis(1,pos=0,xaxp=c(a,b,b-a)) #,xaxp=c(a,b,b-a) axis(2,pos=0,las=2,yaxp=c(a,b,b-a)) # ,yaxp=c(a,b,b-a) #------ fin du repère xA = 2 yA = 3 points(xA,yA,pch=4,cex=1.5) text(xA,yA,TeX("$A$"),pos=1,cex=1.5,col="blue",offset=1.1) dev.off() # #fin image #############################################
Segment dans un repère

library(latex2exp) ############################################# # debut image # png( "geo_segment.png", width = 500, height = 500 ) #------ début du repere a=-6 b=6 plot(0,0, xlim=c(a,b), ylim=c(a,b), xaxs="i", yaxs="i", asp=1, axes=FALSE, xaxp=c(a,b,b-a), yaxp=c(a,b,b-a), panel.first = grid(nx=b-a,ny=b-a), xlab=NA, ylab=NA, type="l", lwd=2, col="red") axis(1,pos=0,xaxp=c(a,b,b-a)) #,xaxp=c(a,b,b-a) axis(2,pos=0,las=2,yaxp=c(a,b,b-a)) # ,yaxp=c(a,b,b-a) #------ fin du repère xA = 2 yA = 3 points(xA,yA,pch=4,cex=1.) text(xA,yA,TeX("$A$"),pos=1,cex=1.5,col="blue",offset=1.1) xB = 4 yB = 5 points(xB,yB,pch=4,cex=1.) text(xB,yB,TeX("$B$"),pos=1,cex=1.5,col="blue",offset=1.1) segments(xA,yA,xB,yB,cex=1.5,col="blue",lwd=2) dev.off() # #fin image #############################################
Vecteur dans un repère

library(latex2exp) ############################################# # debut image # png( "geo_vecteur.png", width = 500, height = 500 ) #------ début du repere a=-6 b=6 plot(0,0, xlim=c(a,b), ylim=c(a,b), xaxs="i", yaxs="i", asp=1, axes=FALSE, xaxp=c(a,b,b-a), yaxp=c(a,b,b-a), panel.first = grid(nx=b-a,ny=b-a), xlab=NA, ylab=NA, type="l", lwd=2, col="red") axis(1,pos=0,xaxp=c(a,b,b-a)) #,xaxp=c(a,b,b-a) axis(2,pos=0,las=2,yaxp=c(a,b,b-a)) # ,yaxp=c(a,b,b-a) #------ fin du repère xA = 2 yA = 3 points(xA,yA,pch=4,cex=1.) text(xA,yA,TeX("$A$"),pos=1,cex=1.5,col="blue",offset=1.1) xB = 4 yB = 5 points(xB,yB,pch=4,cex=1.) text(xB,yB,TeX("$B$"),pos=4,cex=1.5,col="blue",offset=1.1) arrows(xA,yA,xB,yB,cex=1.5,col="blue",lwd=2,length=0.15) dev.off() # #fin image #############################################
Droite dans un repère

library(latex2exp) ############################################# # debut image # png( "geo_droite.png", width = 500, height = 500 ) #------ début du repere a=-6 b=6 plot(0,0, xlim=c(a,b), ylim=c(a,b), xaxs="i", yaxs="i", asp=1, axes=FALSE, xaxp=c(a,b,b-a), yaxp=c(a,b,b-a), panel.first = grid(nx=b-a,ny=b-a), xlab=NA, ylab=NA, type="l", lwd=2, col="red") axis(1,pos=0,xaxp=c(a,b,b-a)) #,xaxp=c(a,b,b-a) axis(2,pos=0,las=2,yaxp=c(a,b,b-a)) # ,yaxp=c(a,b,b-a) #------ fin du repère xA = 2 yA = 3 points(xA,yA,pch=4,cex=1.) text(xA,yA,TeX("$A$"),pos=1,cex=1.5,col="blue",offset=1.1) xB = 4 yB = 5 points(xB,yB,pch=4,cex=1.) text(xB,yB,TeX("$B$"),pos=1,cex=1.5,col="blue",offset=1.1) f = function(x) { a = (yB-yA)/(xB-xA) b = yA-a*xA return(a*x+b) } x = a+ c(0:100)/100*(b-a) ; y = f(x) points(x,y,type="l",lwd=2,col="blue") xnom = -4 text(xnom,f(xnom),TeX("$(d)$"),pos=3,cex=1.5,col="blue",offset=1.1) dev.off() # #fin image #############################################
Polygone dans un repère

library(latex2exp) ############################################# # debut image # png( "geo_polygone.png", width = 500, height = 500 ) #------ début du repere a=-6 b=6 plot(0,0, xlim=c(a,b), ylim=c(a,b), xaxs="i", yaxs="i", asp=1, axes=FALSE, xaxp=c(a,b,b-a), yaxp=c(a,b,b-a), panel.first = grid(nx=b-a,ny=b-a), xlab=NA, ylab=NA, type="l", lwd=2, col="red") axis(1,pos=0,xaxp=c(a,b,b-a)) #,xaxp=c(a,b,b-a) axis(2,pos=0,las=2,yaxp=c(a,b,b-a)) # ,yaxp=c(a,b,b-a) #------ fin du repère xA = 2 yA = 3 points(xA,yA,pch=4,cex=1.) text(xA,yA,TeX("$A$"),pos=2,cex=1.5,col="blue",offset=1.1) xB = 4 yB = 5 points(xB,yB,pch=3,cex=1.) text(xB,yB,TeX("$B$"),pos=4,cex=1.5,col="blue",offset=1.1) xC = 3 yC = -2 points(xC,yC,pch=4,cex=1.) text(xC,yC,TeX("$C$"),pos=1,cex=1.5,col="blue",offset=1.1) polygon(c(xA,xB,xC),c(yA,yB,yC), xpd = TRUE, col = rgb(0,0,1,0.5), lty = 1, lwd = 1, border = "black") dev.off() # #fin image #############################################