-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathF1 png big.R
133 lines (107 loc) · 5.16 KB
/
F1 png big.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
source ('./common_graph_settings.R')
s = 3
offset = 0.01
mtext.title = 2*s
mtext.subtitle = 1.5*s
mtext.sign = 1.2*s
mtext.sign.emo = 1.5*s
png ('./figures/F1_big.png', width=1280*s, height=905.5*s, res=96)
par(mfrow=c(1,1), # number and distribution of plots
oma=c(1,0,3,0), # size of the outer margins in lines of text (can be specified in inches as well with `omi`)
mar=c(1,4,1,1), # number of lines of margin to be specified on the four sides of the plot (can be specified in inches as well with `mai`)
bty='n', # no box
cex = 1.25*s, # magnification of text and symbols
xpd = FALSE, # clipping of plotting to the figure region
ann = FALSE, # switch off titles,
#yaxt = 'n', # switch off y axis, do not do this here, it cannot be overriden with axis()
#xaxt = 'n', # switch off x axis
bg=background.color, # background color
family='Quattrocento' # font family
)
plot(NULL, xlim=c(1, dim(pt)[1]), ylim=c(-y.min, y.max), yaxt = 'n', xaxt = 'n')
axis (2,
line = 0, # position
tck = -0.01,
lwd = 1*s,
col = dark.color, # the actual axis (line)
col.axis = dark.color, # colors of the actual labels
cex.axis = 1,
font=2, # font type (bold)
at=seq(-y.min, y.max, 10), # where to put labels
labels= paste0(c(rev(seq(0, y.min, 10)), seq(10, y.max,10)), "%"), # text of labels
las=1 # orientation of the labels
)
for (i in 1:dim(pt)[1]){
rect(xleft = i - 0.25, xright = i + 0.25, ybottom = 0 - pt[i , 'Allow none'], ytop = 0, col=red.1, border=red.1)
rect(xleft = i - 0.25, xright = i + 0.25, ybottom = 0, ytop = 0 + pt$someplus[i], col=green.light, border=green.light)
rect(xleft = i - 0.25, xright = i + 0.25, ybottom = 0, ytop = 0 + pt[i , 'Allow a few'] + pt[i , 'Allow some'], col=green.1, border=green.1)
rect(xleft = i - 0.25, xright = i + 0.25, ybottom = 0, ytop = 0 + pt[i , 'Allow some'], col=green.dark, border=green.dark)
}
abline(h=seq(-50,100,10), col='white', lwd=1*s)
abline(h=0, col='white', lwd=3*s)
# do that now so it is not crossed by the gridlines
for (i in 1:dim(pt)[1]){
text (rownames(pt)[i], x = i, y = 0 + pt$someplus[i] + 4, font=2)
addImg(readPNG(paste0('./flags/197373-countrys-flags/png/', gsub(" ","-", tolower(countrycode(rownames(pt)[i], origin = 'iso2c', destination = 'country.name'))), '.png')),
x = i, y = 0 - pt[i , 'Allow none'] - 7, width = 0.6)
}
#title
mtext(expression(bold('Allow many/few immigrants from poorer countries in Europe to come and live here')),
side = 3, line = 2, adj = 0, padj = 1, outer = TRUE, at = offset,
font=1, col=dark.color, cex = mtext.title)
mtext(expression(italic("Share of people who answer: 'None' 'Some' 'A few' 'Many'")),
side = 3, line = 0, adj = 0, padj = 1, outer = TRUE, at = offset,
font=1, col=dark.color, cex = mtext.subtitle)
par(xpd = TRUE)
points(x = 5.4, y = 118, pch = 15, cex = 10, col=red.1)
points(x = 5.4 + 3.7, y = 118, pch = 15, cex = 10, col=green.dark)
points(x = 5.4 + 2*3.7, y = 118, pch = 15, cex = 10, col=green.1)
points(x = 5.4 + 3*3.7, y = 118, pch = 15, cex = 10, col=green.light)
#data statement
mtext(text = fontawesome('fa-table'),
side=1, line=-1, outer=T,
col=red.1, cex=mtext.sign.emo, at = offset,
font=1, family='fontawesome-webfont',
adj=0, padj=0.8)
mtext(text=expression("Data: " * phantom("European Social Survey, Wave 7 [2014]")),
side=1, line=-1, outer=T, at = offset + 0.03,
col=dark.color, cex=mtext.sign,
font=1, family='Quattrocento Sans',
adj=0, padj=1)
mtext(text=expression(phantom("Data: ") * "European Social Survey, Wave 7 [2014]"),
side=1, line=-1, outer=T, at = offset + 0.03,
col=red.1, cex=mtext.sign,
font=1, family='Quattrocento Sans',
adj=0, padj=1)
#signature
mtext(text=expression(phantom("@DToshkov ") * " http://dimiter" * phantom(".eu")),
side=1, line=-1, outer=T, at = 1 - offset - 0.02,
col=dark.color, cex=mtext.sign,
font=1, family='Quattrocento Sans',
adj=1, padj=1)
mtext(text=expression(phantom("@DToshkov http://dimiter") * ".eu"),
side=1, line=-1, outer=T, at = 1 - offset - 0.02,
col=red.1, cex=mtext.sign,
font=1, family='Quattrocento Sans',
adj=1, padj=1)
mtext(text=expression("@DToshkov " * phantom(" http://dimiter.eu")),
side=1, line=-1, outer=T, at = 1 - offset - 0.02,
col=blue.twitter, cex=mtext.sign,
font=1, family='Quattrocento Sans',
adj=1, padj=1)
mtext(text= fontawesome('fa-creative-commons'),
side=1, line=-1, outer=T,
col=dark.color, cex=mtext.sign.emo, at = 1 - 0.26,
font=1, family='fontawesome-webfont',
adj=1, padj=0.8)
mtext(text= fontawesome('fa-twitter'),
side=1, line=-1, outer=T,
col=blue.twitter, cex=mtext.sign.emo, at = 1 - 0.15,
font=1, family='fontawesome-webfont',
adj=1, padj=0.8)
mtext(text= fontawesome('fa-rss'),
side=1, line=-1, outer=T,
col=red.1, cex=mtext.sign.emo, at = 1 - offset,
font=1, family='fontawesome-webfont',
adj=1, padj=0.8)
dev.off()