source("http://macosa.dima.unige.it/r.R") # If I have not already loaded the library ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- # With the text command I can put more sophisticated scripts than the ones that can be # made with the type command. I can color them, put them in bold or italics, dimension # them; with text(x,y,script, font=N) I have them in bold if N is 2, italics if 3, bold # +italics if 4. text( ,cex= ) with in a number >1 / <1 (ie 0.8 and 1.2) yelds larger # or smaller scripts. If I put \n a "new line" is inserted. # If desired, I can align left or right of x,y with text( ,adj=0) or text( ,adj=1) # I can tilt the scripts: text( , srt=-90), text( , srt=45) ("srt" is instead of "string # rotation") rotate the script -90° or 45° with respect to the x axis direction. BF=4;HF=4; PLANEww(-2.7,2.7, -2.7,2.7) # (first i should use PLANE to see the grid and then rewrite with PLANEww) x <- c(-1,1,1,-1); y <- c(-1,-1,1,1) polyS(x-1/4,y-1/4, -45, "blue"); polyS(x+1/4,y+1/4, 45, "brown") text( 0.25, 1.5, "resident population", col="brown") text(-0.25,-1.5, "present population", col="blue") dart(1,0,2,0,"brown"); dart2(2,-0.4,"brown") text(2.1,-0.75, "temporary\nemigrants", col="brown") dart(-1,0,-2,0,"blue"); dart2(-2,0.4,"blue") text(-2.1,0.75, "temporary\nimmigrants", col="blue") # dart2 and arrow2 join the tip of the last arrow with the new one # The same goes for Dart2 and Arrow2; the blue arrows reproduced in black: Dart(-1,0,-180,1,"black"); Dart2(90,0.4,"black") # # In text I can use a monospace font with family="mono" BF=2.5; HF=2.5 Planeww(0,10,1,10) # with Plane I have the image on the left # polyC(c(-10,20,20,-10),c(-10,-10,20,20),"yellow") # for yellow background text(5,9,"85000:5000",font=4,family="mono",col="red") text(5,9,"85 :5 ",font=4,family="mono") arrow(5,8,5,7, "blue") text(3,6,"85",font=2,adj=0,family="mono") text(3,5,"50",font=2,adj=0,family="mono") text(3,4,"35",font=2,adj=0,family="mono") text(3,3,"35",font=2,adj=0,family="mono") text(3,2," 0",font=2,adj=0,family="mono",col="blue") line(4.5,6.5,4.5,1.5, 1) line(4,4.5,2.5,4.5, 1) line(4,2.5,2.5,2.5, 1) text(5.5,6,"5",font=2,adj=0,family="mono") text(5.5,5,"10",font=2,adj=0,family="mono") line(4.5,5.5,6.7,5.5, 1) text(5.5,4," 7",font=2,adj=0,family="mono") line(4.5,3.5,6.7,3.5, 1) text(5.5,3,"17",font=2,adj=0,family="mono",col="blue") # # How to use polySN(x,y, angle, N, col) (with N=1 it is as polyS, with # N=2 it is as polyS2, ...) BF=2.1; HF=2 BOXW(5,200,-45,160) # gridh(seq(-50,200,10)); gridv(seq(0,200,10)) # line(-30,0, 230,0, "blue") ax=c(57,10,8,27,48,57,45,67,75,57) ay=c(158,121,78,43,47,72,101,112,130,158) polylin(ax,ay,"black") bx=c(27,48,57, 45, 67, 75,62,112,112,78,115,101,27) by=c(43,47,72,101,112,130,150,150,118,103,35.5,25,43) polylin(bx,by,"black") cx=c(112,78,115,184,168,112,112) cy=c(118,103,35.5,87,145,144,118) polylin(cx,cy,"black") dx=c(168,184,101,178,197,168) dy=c(145, 87, 25, 4,115,145) polySN(ax,ay, 45, 1.5,"black") polySN(bx,by, 45/2, 2.5,"black") polySN(cx,cy, 45-90, 1,"black") polySN(dx,dy,45/2-90, 2,"black") polySN(c(10,35,35,10,10)+5,c(0,0,-25,-25,0)-5, 45, 1.5,"black") polySN(c(10,35,35,10,10)+50,c(0,0,-25,-25,0)-5, 45/2, 2.5,"black") polySN(c(10,35,35,10,10)+95,c(0,0,-25,-25,0)-5, 45-90, 1,"black") polySN(c(10,35,35,10,10)+140,c(0,0,-25,-25,0)-5,45/2-90, 2,"black") c = (10+35)/2 text(c+5,-38,"0-10",cex=0.75); text(c+50,-38,"10-20",cex=0.75) text(c+95,-38,"20-30",cex=0.75); text(c+140,-38,"30-+",cex=0.75) text(c+170,-18,"%",cex=0.75)