An error occurred while loading the file. Please try again.
-
Heraut Louis authoredf1913791
# Usefull library
library(ggplot2)
library(gridExtra)
width = 30
height = 14
dpi = 100
# Time panel
panel = function (df_data, df_info, figdir, filedir, is_sqrt=FALSE) {
outfile = "Panels"
if (is_sqrt) {
df_data[, 'Qm3s'] = apply(df_data[, 'Qm3s'], 1, sqrt)
outfile = paste(outfile, '_sqrt', sep='')
}
outfile = paste(outfile, '.pdf', sep='')
# If there is not a dedicated figure directory it creats one
outdir = file.path(figdir, filedir, sep='')
if (!(file.exists(outdir))) {
dir.create(outdir)
}
# Get all different stations code
Code = levels(factor(df_info$code))
# Create a blank list in order to store plots
plots = list()
for (code in Code) {
# Print code of the station for the current plotting
print(paste("Plotting for sation :", code))
df_data_code = df_data[df_data$code==code,]
# df_data_code_NoNA = df_data_code[!is.na(df_data_code$Qm3s),]
# Plot
p = ggplot(df_data_code, aes(x=Date, y=Qm3s)) +
geom_line()
# Store
plots = append(plots, list(p))
}
# Saving
ggsave(path=outdir,
filename=outfile,
plot=marrangeGrob(plots, nrow=1, ncol=1),
width=29.7, height=21, units='cm', dpi=100
)
}