Newer
Older
annotate('text', x=Xc_mean, y=max(Y) + 0.9,
label=bquote(bold('Début')),
size=3, color='grey20') +
annotate('text', x=Xc_mean, y=max(Y) + 0.63,
label=bquote(bold('Fin')),
size=3, color='grey20')
# For all variables
for (i in 1:nbpMod) {
# Extract the variable of the plot
var = subVar_mean[i]
type = subType_mean[i]
# If it is a flow variable
if (type == 'sévérité') {
# Fixes the unit of the mean and the break
# for the flow
unit_mean = bquote('['*m^3*'.'*s^{-1}*']')
unit_break = bquote('[%]')
# If it is a date variable
# Fixes the unit of the mean and the break
# for the date
} else if (type == 'saisonnalité') {
unit_mean = bquote('[jour]')
unit_break = bquote('[jour]')
}
# 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')
}
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
# 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")
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
# 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
}
type, sep='')
subsection = title
n_page = df_page$n[nrow(df_page)] + 1
df_page = bind_rows(
df_page,
tibble(section=section,
subsection=subsection,
n=n_page))
}
footName = paste('tableau récapitulatif de ',
type, sep='')
if (is.null(df_page)) {
n_page = n_loop
}
foot = foot_panel(footName,
n_page,
AEAGlogo_file, INRAElogo_file,
FRlogo_file, foot_height)
P = list(mat, foot)
LM = matrix(c(1,
2),
nrow=2, byrow=TRUE)
} else {
foot_height = 0
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)
row_height = (height - 2*margin_size - foot_height) / (LMrow - 3)
Hcut = LM[, 2]
heightLM = rep(row_height, times=LMrow)
heightLM[Hcut == id_foot] = foot_height
Wcut = LM[(nrow(LM)-1),]
widthLM = rep(col_width, times=LMcol)
# 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)