Newer
Older
# Writes the unit of the averaged variable
annotate('text',
x=Xm_mean[i], y=max(Y) + 0.63,
# Writes the type of the averaged variable
annotate('text',
x=Xm_mean[i], y=max(Y) + 0.9,
label=expr(bar(!!var)),
hjust=0.5, vjust=0.5,
# If this is not the first period
if (j > 1) {
mat = mat +
# Writes the unit of the breaking variable
annotate('text', x=Xr_mean[i],
y=max(Y) + 0.63,
hjust=0.5, vjust=0.5,
size=2, color='grey40') +
# Writes the type of the breaking variable
annotate('text', x=Xr_mean[i],
y=max(Y) + 0.9,
label=paste("d", var, sep=''),
hjust=0.5, vjust=0.5,
size=3.25, color='grey20')
}
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
# For all the station on the page
for (k in 1:nsubCode) {
# Gets the code
code = subCode[k]
# Extracts label for the period dates
label = Periods_mean_per[Code_mean_per == code][1]
# Gets the start and end of the period
# for the station
periodStart = substr(label, 1, 4)
periodEnd = substr(label, 14, 17)
mat = mat +
# # Writes the starting value
annotate('text', x=Xc_mean, y=k + 0.13,
label=bquote(bold(.(periodStart))),
hjust=0.5, vjust=0.5,
size=3, color='grey40') +
# Writes the ending value
annotate('text', x=Xc_mean, y=k - 0.13,
label=bquote(bold(.(periodEnd))),
hjust=0.5, vjust=0.5,
size=3, color='grey40')
}
}
### Code ###
# For all the station
# Gets the name of the station
name = df_meta[df_meta$code == code,]$nom
# Fixes a limit for the max number
# of characters available
ncharMax = 38
# If the number of character of the name is greater
# than the limit
if (nchar(name) > ncharMax) {
# Cuts the name and add '...'
name = paste(substr(name, 1, ncharMax),
'...', sep='')
}
# Writes the code of the station
annotate('text', x=0.3, y=k + 0.14,
label=bquote(bold(.(code))),
hjust=1, vjust=0.5,
size=3.5, color="#00A3A8") +
# Writes the name of the station
annotate('text', x=0.3, y=k - 0.14,
label=name,
hjust=1, vjust=0.5,
size=3.5, color="#00A3A8")
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# Fixed coordinate system
coord_fixed() +
# X axis
scale_x_continuous(limits=c(1 - rel(6),
width + rel(0.5)),
expand=c(0, 0)) +
# Y axis
scale_y_continuous(limits=c(1 - rel(0.5),
height + rel(2)),
expand=c(0, 0))
# Paper format in A3 if needed
if (A3) {
width = 42
height = 29.7
dpi = 300
# Otherwise in A4
} else {
width = 29.7
height = 21
dpi = 100
}
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
# If there is a foot note
if (foot_note) {
foot = foot_panel('tableau récapitulatif',
n_page, N_page,
resources_path,
AEAGlogo_file, INRAElogo_file,
FRlogo_file, foot_height)
# Stores the map, the title and the colorbar in a list
P = list(mat, foot)
LM = matrix(c(1,
2),
nrow=2, byrow=TRUE)
} else {
foot_height = 0
# Stores the map, the title and the colorbar in a list
P = list(mat)
LM = matrix(c(1),
nrow=1, byrow=TRUE)
}
id_foot = 2
LMcol = ncol(LM)
LMrow = nrow(LM)
LM = rbind(rep(99, times=LMcol),
LM, rep(99, times=LMcol))
LMrow = nrow(LM)
LM = cbind(rep(99, times=LMrow),
LM, rep(99, times=LMrow))
LMcol = ncol(LM)
margin_height = 0.5
row_height = (height - 2*margin_height - foot_height) / (LMrow - 3)
Hcut = LM[, 2]
heightLM = rep(row_height, times=LMrow)
heightLM[Hcut == id_foot] = foot_height
heightLM[Hcut == 99] = margin_height
col_width = (width - 2*margin_height) / (LMcol - 2)
Wcut = LM[(nrow(LM)-1),]
widthLM = rep(col_width, times=LMcol)
widthLM[Wcut == 99] = margin_height
# Arranges the graphical object
plot = grid.arrange(grobs=P, layout_matrix=LM,
heights=heightLM, widths=widthLM)
path=outdirTmp,
filename=paste(outnameTmp,
'_', type,
'_', fL,
iMat, sep=''),
device='pdf',
width=width, height=height,
units='cm', dpi=dpi)