Commit a8db14e8 authored by Heraut Louis's avatar Heraut Louis
Browse files

Cleaned and commented

parent 91c10c3e
No related merge requests found
Showing with 119 additions and 63 deletions
+119 -63
...@@ -207,12 +207,17 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' ...@@ -207,12 +207,17 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp=''
sizerv = 0.2 sizerv = 0.2
} }
# Stores the coordonate system
cf = coord_fixed()
# Makes it the default one to remove useless warning
cf$default = TRUE
# Open a new plot with the personalise theme # Open a new plot with the personalise theme
map = ggplot() + theme_void() + map = ggplot() + theme_void() +
# theme(plot.background=element_rect(fill=NA, # theme(plot.background=element_rect(fill=NA,
# color="#EC4899")) + # color="#EC4899")) +
# Fixed coordinate system # Fixed coordinate system (remove useless warning)
coord_fixed() + cf +
# Plot the background of France # Plot the background of France
geom_polygon(data=df_france, geom_polygon(data=df_france,
aes(x=long, y=lat, group=group), aes(x=long, y=lat, group=group),
......
...@@ -162,7 +162,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -162,7 +162,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# If the p value is under the threshold # If the p value is under the threshold
if (df_trend_code_per$p <= p_threshold){ if (df_trend_code_per$p <= p_threshold){
# Stores the mean trend # Stores the averaged trend
TrendMean_code[j, i, k] = trendMean TrendMean_code[j, i, k] = trendMean
# Otherwise # Otherwise
} else { } else {
...@@ -235,7 +235,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -235,7 +235,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# If the p value is under the threshold # If the p value is under the threshold
if (df_trend_code_per$p <= p_threshold){ if (df_trend_code_per$p <= p_threshold){
# Gets the color associated to the mean trend # Gets the color associated to the averaged trend
color_res = get_color(trendMean, color_res = get_color(trendMean,
minTrendMean[j, i], minTrendMean[j, i],
maxTrendMean[j, i], maxTrendMean[j, i],
...@@ -269,7 +269,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -269,7 +269,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# If there is a 'mean_period' # If there is a 'mean_period'
if (!is.null(mean_period)) { if (!is.null(mean_period)) {
# Blank vectors to store info about mean analyses # Blank vectors to store info about breaking analysis
Periods_mean = c() Periods_mean = c()
NPeriod_mean = c() NPeriod_mean = c()
Type_mean = list() Type_mean = list()
...@@ -290,7 +290,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -290,7 +290,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
dataMeantmp = array(rep(NA, nbp*nCode), dataMeantmp = array(rep(NA, nbp*nCode),
dim=c(nbp, nCode)) dim=c(nbp, nCode))
# For all mean period # For all period of breaking analysis
for (j in 1:nPeriod_mean) { for (j in 1:nPeriod_mean) {
# For all the code # For all the code
for (k in 1:nCode) { for (k in 1:nCode) {
...@@ -354,7 +354,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -354,7 +354,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
} }
} }
} }
# Computes the min and the max of the mean trend for # Computes the min and the max of the averaged trend for
# all the station # all the station
minBreakMean = apply(BreakMean_code, c(1, 2), minBreakMean = apply(BreakMean_code, c(1, 2),
min, na.rm=TRUE) min, na.rm=TRUE)
...@@ -372,7 +372,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -372,7 +372,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
code = Code[k] code = Code[k]
# For all variable # For all variable
for (i in 1:nbp) { for (i in 1:nbp) {
# Extracts break mean # Extracts averaged breaking
BreakMean = BreakMean_mean[ii] BreakMean = BreakMean_mean[ii]
# Gets the color associated # Gets the color associated
color_res = get_color(BreakMean, color_res = get_color(BreakMean,
...@@ -435,7 +435,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -435,7 +435,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
subFill_trend = Fill_trend[CodefL_trend] subFill_trend = Fill_trend[CodefL_trend]
subColor_trend = Color_trend[CodefL_trend] subColor_trend = Color_trend[CodefL_trend]
# Same for mean difference analysis # Same for breaking analysis
CodefL_mean = Code_mean %in% subCode CodefL_mean = Code_mean %in% subCode
# Extracts right info # Extracts right info
subPeriods_mean = Periods_mean[CodefL_mean] subPeriods_mean = Periods_mean[CodefL_mean]
...@@ -506,12 +506,12 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -506,12 +506,12 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# Converts the vector of hydrological variable to # Converts the vector of hydrological variable to
# a vector of integer associated to those variable # a vector of integer associated to those variable
Xtmp = as.integer(factor(as.character(Type_trend_per))) Xtmp = as.integer(factor(as.character(Type_trend_per)))
# Computes X position of the column of the period dates # Computes X position of the column for the period dates
Xc = j + (j - 1)*nbp*2 Xc = j + (j - 1)*nbp*2
# Computes X positions of columns of the mean of # Computes X positions of columns for the mean of
# variables # variables
Xm = Xtmp + (j - 1)*nbp*2 + j Xm = Xtmp + (j - 1)*nbp*2 + j
# Computes X positions of columns of the mean trend # Computes X positions of columns for the averaged trend
X = Xtmp + (j - 1)*nbp*2 + nbp + j X = Xtmp + (j - 1)*nbp*2 + nbp + j
# Computes Y positions of each line for each station # Computes Y positions of each line for each station
...@@ -545,20 +545,20 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -545,20 +545,20 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# For all the variable # For all the variable
for (i in 1:length(X)) { for (i in 1:length(X)) {
mat = mat + mat = mat +
# Plots circles for mean trends # Plots circles for averaged trends
gg_circle(r=0.45, xc=X[i], yc=Y[i], gg_circle(r=0.45, xc=X[i], yc=Y[i],
fill=Fill_trend_per[i], fill=Fill_trend_per[i],
color=Color_trend_per[i]) + color=Color_trend_per[i]) +
# Plots circles for mean of variables # Plots circles for averaged of variables
gg_circle(r=0.45, xc=Xm[i], yc=Y[i], gg_circle(r=0.45, xc=Xm[i], yc=Y[i],
fill='white', color='grey40') + fill='white', color='grey40') +
# Plots circles for the column of period dates # Plots circles for the column of period dates
gg_circle(r=0.45, xc=Xc, yc=Y[i], gg_circle(r=0.45, xc=Xc, yc=Y[i],
fill='white', color='grey40') fill='white', color='grey40')
} }
# For all the mean trend on this period # For all averaged trends on this periods
for (i in 1:length(TrendMean_trend_per)) { for (i in 1:length(TrendMean_trend_per)) {
# Extracts the value of the mean trend # Extracts the value of the averaged trend
trendMean = TrendMean_trend_per[i] trendMean = TrendMean_trend_per[i]
# Converts it to the right format with two # Converts it to the right format with two
# significant figures # significant figures
...@@ -574,7 +574,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -574,7 +574,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
Tcolor = 'grey85' Tcolor = 'grey85'
} }
# Same for the mean of a variable over # Same for averaged variables over
# the current period # the current period
dataMean = DataMean_trend_per[i] dataMean = DataMean_trend_per[i]
dataMeanC = signif(dataMean, 2) dataMeanC = signif(dataMean, 2)
...@@ -592,8 +592,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -592,8 +592,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
size=3, color='grey40') size=3, color='grey40')
} }
# Writes a name for the period dates column
mat = mat + mat = mat +
# Writes a name for the period dates column
annotate('text', x=Xc, y=max(Y) + 0.85, annotate('text', x=Xc, y=max(Y) + 0.85,
label=bquote(bold('Début')), label=bquote(bold('Début')),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
...@@ -618,12 +618,12 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -618,12 +618,12 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
label=bquote('[%.'*ans^{-1}*']'), label=bquote('[%.'*ans^{-1}*']'),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=2, color='grey40') + size=2, color='grey40') +
# Writes the type of the mean variable # Writes the type of the averaged variable
annotate('text', x=Xm[i], y=max(Y) + 0.82, annotate('text', x=Xm[i], y=max(Y) + 0.82,
label=bquote('µ'*.(type)), label=bquote('µ'*.(type)),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3.25, color='grey20') + size=3.25, color='grey20') +
# Writes the unit of the mean variable # Writes the unit of the averaged variable
annotate('text', x=Xm[i], y=max(Y) + 0.6, annotate('text', x=Xm[i], y=max(Y) + 0.6,
label=bquote('['*m^3*'.'*s^{-1}*']'), label=bquote('['*m^3*'.'*s^{-1}*']'),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
...@@ -634,18 +634,21 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -634,18 +634,21 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
for (k in 1:nsubCode) { for (k in 1:nsubCode) {
# Gets the code # Gets the code
code = subCode[k] code = subCode[k]
# Extracts label for the period dates
label = Periods_trend[subNPeriod_trend == j label = Periods_trend[subNPeriod_trend == j
& subCode_trend == code][1] & subCode_trend == code][1]
# Gets the start and end of the period
# for the station
periodStart = substr(label, 1, 4) periodStart = substr(label, 1, 4)
periodEnd = substr(label, 14, 17) periodEnd = substr(label, 14, 17)
mat = mat + mat = mat +
# Writes the starting value
annotate('text', x=Xc, y=k + 0.13, annotate('text', x=Xc, y=k + 0.13,
label=bquote(bold(.(periodStart))), label=bquote(bold(.(periodStart))),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='grey40') + size=3, color='grey40') +
# Writes the ending value
annotate('text', x=Xc, y=k - 0.13, annotate('text', x=Xc, y=k - 0.13,
label=bquote(bold(.(periodEnd))), label=bquote(bold(.(periodEnd))),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
...@@ -654,8 +657,10 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -654,8 +657,10 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
} }
### Mean ### ### Mean ###
# For all the trend period
for (j in 1:nPeriod_mean) { for (j in 1:nPeriod_mean) {
# Extracts the info to plot associated to the
# right period
Type_mean_per = Type_mean_per =
subType_mean[subNPeriod_mean == j] subType_mean[subNPeriod_mean == j]
Code_mean_per = Code_mean_per =
...@@ -668,148 +673,182 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -668,148 +673,182 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
subFill_mean[subNPeriod_mean == j] subFill_mean[subNPeriod_mean == j]
Color_mean_per = Color_mean_per =
subColor_mean[subNPeriod_mean == j] subColor_mean[subNPeriod_mean == j]
Xtmp_mean = as.integer(factor(as.character(Type_mean_per)))
# Converts the vector of hydrological variable to
# a vector of integer associated to those variable
Xtmp_mean = as.integer(factor(as.character(Type_mean_per)))
# Computes X position of the column for the period dates
Xc_mean = j + (j - 1)*nbp + X[length(X)] Xc_mean = j + (j - 1)*nbp + X[length(X)]
# Computes X positions of columns for the mean of
# variables
Xm_mean = Xtmp_mean + (j - 1)*nbp + j + X[length(X)] Xm_mean = Xtmp_mean + (j - 1)*nbp + j + X[length(X)]
# Computes X positions of columns for the difference of
# mean between periods (break)
Xr_mean = Xtmp_mean + (j - 1)*nbp*2 + j + X[length(X)] Xr_mean = Xtmp_mean + (j - 1)*nbp*2 + j + X[length(X)]
# Computes Y positions of each line for each station
Y_mean = as.integer(factor(Code_mean_per)) Y_mean = as.integer(factor(Code_mean_per))
# Position of a line to delimite periods
x = Xc_mean - 0.4 x = Xc_mean - 0.4
xend = Xm_mean[length(Xm_mean)] + 0.25 xend = Xm_mean[length(Xm_mean)] + 0.25
y = height + 1 y = height + 1
yend = height + 1 yend = height + 1
# Drawing of the line
mat = mat + mat = mat +
annotate("segment", annotate("segment",
x=x, xend=xend, x=x, xend=xend,
y=y, yend=yend, y=y, yend=yend,
color="grey40", size=0.35) color="grey40", size=0.35)
# Position of the name of the current period
yt = y + 0.15 yt = y + 0.15
Start = mean_period[[j]][1] Start = mean_period[[j]][1]
End = mean_period[[j]][2] End = mean_period[[j]][2]
# Name of the period
periodName = bquote(bold('Période')~bold(.(as.character(j+nPeriod_trend)))) periodName = bquote(bold('Période')~bold(.(as.character(j+nPeriod_trend))))
# Naming the period
mat = mat + mat = mat +
annotate("text", x=x, y=yt, annotate("text", x=x, y=yt,
label=periodName, label=periodName,
hjust=0, vjust=0.5, hjust=0, vjust=0.5,
size=3, color='grey40') size=3, color='grey40')
# If this is not the first period
if (j > 1) { if (j > 1) {
# Position of a line to delimite results of
# difference of mean bewteen periods
x = Xr_mean[1] - 0.4 x = Xr_mean[1] - 0.4
xend = Xr_mean[length(Xr_mean)] + 0.25 xend = Xr_mean[length(Xr_mean)] + 0.25
# Drawing of the line
mat = mat + mat = mat +
annotate("segment", annotate("segment",
x=x, xend=xend, x=x, xend=xend,
y=y, yend=yend, y=y, yend=yend,
color="grey40", size=0.35) color="grey40", size=0.35)
# Naming the breaking columns
breakName = bquote(bold('Écart')~bold(.(as.character(j-1+nPeriod_trend)))*bold('-')*bold(.(as.character(j+nPeriod_trend)))) breakName = bquote(bold('Écart')~bold(.(as.character(j-1+nPeriod_trend)))*bold('-')*bold(.(as.character(j+nPeriod_trend))))
# Writes the name
mat = mat + mat = mat +
annotate("text", x=x, y=yt, annotate("text", x=x, y=yt,
label=breakName, label=breakName,
hjust=0, vjust=0.5, hjust=0, vjust=0.5,
size=3, color='grey40') size=3, color='grey40')
} }
# For all the variable
for (i in 1:length(Xm_mean)) { for (i in 1:length(Xm_mean)) {
mat = mat + mat = mat +
# Plots circles for averaged variables
gg_circle(r=0.45, xc=Xm_mean[i], yc=Y[i], gg_circle(r=0.45, xc=Xm_mean[i], yc=Y[i],
fill='white', color='grey40') + fill='white', color='grey40') +
# Plots circles for the column of period dates
gg_circle(r=0.45, xc=Xc_mean, yc=Y[i], gg_circle(r=0.45, xc=Xc_mean, yc=Y[i],
fill='white', color='grey40') fill='white', color='grey40')
# If this is not the first period
if (j > 1) { if (j > 1) {
mat = mat + mat = mat +
# Plots circles for breaking results
gg_circle(r=0.45, xc=Xr_mean[i], yc=Y[i], gg_circle(r=0.45, xc=Xr_mean[i], yc=Y[i],
fill=Fill_mean_per[i], fill=Fill_mean_per[i],
color=Color_mean_per[i]) color=Color_mean_per[i])
} }
} }
# For all averaged variables on this period
for (i in 1:length(DataMean_mean_per)) { for (i in 1:length(DataMean_mean_per)) {
dataMean = signif(DataMean_mean_per[i], 2) # Extracts values of averaged variables
dataMean = DataMean_mean_per[i]
# Converts it to the right format with two
# significant figures
dataMeanC = signif(dataMean, 2)
# Writes averaged variables values
mat = mat + mat = mat +
annotate('text', x=Xm_mean[i], y=Y[i], annotate('text', x=Xm_mean[i], y=Y[i],
label=dataMean, label=dataMeanC,
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='grey40') size=3, color='grey40')
# If this is not the first period
if (j > 1) { if (j > 1) {
# Extracts values of breaking between periods
BreakMean = BreakMean_mean_per[i] BreakMean = BreakMean_mean_per[i]
BreakC = signif(BreakMean*100, 2) # Converts it to the right format with two
# significant figures
BreakMeanC = signif(BreakMean*100, 2)
# Writes breaking values
mat = mat + mat = mat +
annotate('text', x=Xr_mean[i], y=Y[i], annotate('text', x=Xr_mean[i], y=Y[i],
label=BreakC, label=BreakMeanC,
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='white') size=3, color='white')
} }
} }
# Writes a name for the period dates column
mat = mat + mat = mat +
annotate('text', x=Xc_mean, y=max(Y) + 0.85, annotate('text', x=Xc_mean, y=max(Y) + 0.85,
label=bquote(bold('Début')), label=bquote(bold('Début')),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='grey20') + size=3, color='grey20') +
annotate('text', x=Xc_mean, y=max(Y) + 0.6, annotate('text', x=Xc_mean, y=max(Y) + 0.6,
label=bquote(bold('Fin')), label=bquote(bold('Fin')),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='grey20') size=3, color='grey20')
# For all variable
# For all variables
for (i in 1:nbp) { for (i in 1:nbp) {
# Extract the variable of the plot # Extract the variable of the plot
type = list_df2plot[[i]]$type type = list_df2plot[[i]]$type
mat = mat + mat = mat +
# Writes the type of the averaged variable
annotate('text', x=Xm_mean[i], y=max(Y) + 0.82, annotate('text', x=Xm_mean[i], y=max(Y) + 0.82,
label=bquote('µ'*.(type)), label=bquote('µ'*.(type)),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3.25, color='grey20') + size=3.25, color='grey20') +
# Writes the unit of the averaged variable
annotate('text', x=Xm_mean[i], y=max(Y) + 0.6, annotate('text', x=Xm_mean[i], y=max(Y) + 0.6,
label=bquote('['*m^3*'.'*s^{-1}*']'), label=bquote('['*m^3*'.'*s^{-1}*']'),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=2, color='grey40') size=2, color='grey40')
# If this is not the first period
if (j > 1) { if (j > 1) {
mat = mat + mat = mat +
annotate('text', x=Xr_mean[i], y=max(Y) + 0.82, # Writes the type of the breaking variable
annotate('text', x=Xr_mean[i],
y=max(Y) + 0.82,
label=bquote('d'*.(type)), label=bquote('d'*.(type)),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3.25, color='grey20') + size=3.25, color='grey20') +
# Writes the unit of the breaking variable
annotate('text', x=Xr_mean[i], y=max(Y) + 0.6, annotate('text', x=Xr_mean[i],
y=max(Y) + 0.6,
label=bquote('[%]'), label=bquote('[%]'),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=2, color='grey40') size=2, color='grey40')
} }
} }
# For all the station on the page
for (k in 1:nsubCode) { for (k in 1:nsubCode) {
# Gets the code
code = subCode[k] code = subCode[k]
# Extracts label for the period dates
label = Periods_mean[subNPeriod_mean == j label = Periods_mean[subNPeriod_mean == j
& subCode_mean == code][1] & subCode_mean == code][1]
# Gets the start and end of the period
# for the station
periodStart = substr(label, 1, 4) periodStart = substr(label, 1, 4)
periodEnd = substr(label, 14, 17) periodEnd = substr(label, 14, 17)
mat = mat + mat = mat +
# # Writes the starting value
annotate('text', x=Xc_mean, y=k + 0.13, annotate('text', x=Xc_mean, y=k + 0.13,
label=bquote(bold(.(periodStart))), label=bquote(bold(.(periodStart))),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
size=3, color='grey40') + size=3, color='grey40') +
# Writes the ending value
annotate('text', x=Xc_mean, y=k - 0.13, annotate('text', x=Xc_mean, y=k - 0.13,
label=bquote(bold(.(periodEnd))), label=bquote(bold(.(periodEnd))),
hjust=0.5, vjust=0.5, hjust=0.5, vjust=0.5,
...@@ -818,21 +857,30 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -818,21 +857,30 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
} }
### Code ### ### Code ###
# For all the station
for (k in 1:nsubCode) { for (k in 1:nsubCode) {
# Gets the code # Gets the code
code = subCode[k] code = subCode[k]
# Gets the name of the station
name = df_meta[df_meta$code == code,]$nom name = df_meta[df_meta$code == code,]$nom
# Fixes a limit for the max number
# of characters available
ncharMax = 38 ncharMax = 38
# If the number of character of the name is greater
# than the limit
if (nchar(name) > ncharMax) { if (nchar(name) > ncharMax) {
name = paste(substr(name, 1, ncharMax), '...', sep='') # Cuts the name and add '...'
name = paste(substr(name, 1, ncharMax),
'...', sep='')
} }
mat = mat + mat = mat +
# Writes the code of the station
annotate('text', x=0.3, y=k + 0.14, annotate('text', x=0.3, y=k + 0.14,
label=bquote(bold(.(code))), label=bquote(bold(.(code))),
hjust=1, vjust=0.5, hjust=1, vjust=0.5,
size=3.5, color="#00A3A8") + size=3.5, color="#00A3A8") +
# Writes the name of the station
annotate('text', x=0.3, y=k - 0.14, annotate('text', x=0.3, y=k - 0.14,
label=name, label=name,
hjust=1, vjust=0.5, hjust=1, vjust=0.5,
...@@ -843,31 +891,34 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice ...@@ -843,31 +891,34 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
mat = mat + mat = mat +
# Fixed coordinate system # Fixed coordinate system
coord_fixed() + coord_fixed() +
# X axis
scale_x_continuous(limits=c(1 - rel(6), scale_x_continuous(limits=c(1 - rel(6),
width + rel(0.5)), width + rel(0.5)),
expand=c(0, 0)) + expand=c(0, 0)) +
# Y axis
scale_y_continuous(limits=c(1 - rel(0.5), scale_y_continuous(limits=c(1 - rel(0.5),
height + rel(2)), height + rel(2)),
expand=c(0, 0)) expand=c(0, 0))
# Saving matrix plot # Paper format in A3 if needed
if (A3) { if (A3) {
width = 42 width = 42
height = 29.7 height = 29.7
dpi = 300 dpi = 300
# Otherwise in A4
} else { } else {
width = 29.7 width = 29.7
height = 21 height = 21
dpi = 100 dpi = 100
} }
# Saving
ggsave(plot=mat, ggsave(plot=mat,
path=outdirTmp, path=outdirTmp,
filename=paste(outnameTmp, '_', fL, imat, '.pdf', filename=paste(outnameTmp, '_', fL,
sep=''), imat, '.pdf', sep=''),
width=width, height=height, units='cm', dpi=dpi) width=width, height=height,
units='cm', dpi=dpi)
} }
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment