-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaprespondant_fig.R
63 lines (52 loc) · 2.58 KB
/
maprespondant_fig.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
##############################################################################/
##############################################################################/
#Code for the worl map
##############################################################################/
##############################################################################/
#this code was originaly written by Pauline De Jerphanion and modified by
#Benoit Barrès
#loading the packages and the data necessary for the analysis
source("dataloading.R")
##############################################################################/
#Figure 2A: World map of the responding countries####
##############################################################################/
#preparing the data
data_country_total<-as.data.frame(table(data_repondants$q2))
colnames(data_country_total)<-c("country","total")
#getting colours
colourPalette <- brewer.pal(5,'Oranges')[2:5]
#first get countries excluding Antarctica which crashes spTransform
sPDF <- getMap()[-which(getMap()$ADMIN=="Antarctica"),]
#Ajout des données au shapefile
sPDF <- joinCountryData2Map(data_country_total
, joinCode='NAME'
, nameJoinColumn='country'
, verbose='TRUE')
#transform to robin for the Robinson projection
sPDF <- spTransform(sPDF, CRS=CRS("+proj=robin +ellps=WGS84"))
#plotting the distribution of the area of the different countries
plot(gArea(sPDF,byid=TRUE))
#plot map
op<-par(oma=c(0,0,0,0),mar=c(0,0,0,9))
par(xpd=TRUE)
mapParams <- mapCountryData(sPDF[which(sPDF@data$ADMIN!="Antarctica" &
gArea(sPDF,byid=TRUE)>20000000000 ),]
,nameColumnToPlot="total"
,mapTitle=""
,addLegend=FALSE
,catMethod = c(0,1,2,6,12)
,colourPalette = colourPalette
,oceanCol = "white"
,missingCountryCol = "white"
,borderCol="black"
,lwd=0.8)
legend(16000000,6000000,pch=21,
pt.bg=c("white",colourPalette[1:4]),#title="Number of\nrespondents",
legend=c("0","1","2","[3-6]","[7-10]"),text.width=60000000,
cex=1.3,pt.cex=3,col="black",bg=NA,bty="n",ncol=1,xjust=0,
x.intersp=0.4,y.intersp=0.6,title.adj=0.03)
par(op)
#export to pdf 15 x 7 inches
##############################################################################/
#END
##############################################################################/