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

Plot modularity

parent 4488c0bd
No related merge requests found
Showing with 36 additions and 21 deletions
+36 -21
......@@ -173,13 +173,25 @@ panel = function (df_data, df_meta, layout_matrix, figdir='', filedir_opt='', fi
time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day, type, last=FALSE) {
time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day, type, norm=TRUE, last=FALSE) {
df_data_code = df_data[df_data$code == code,]
if (type == 'sqrt') {
df_data[, 'Qm3s'] = apply(df_data[, 'Qm3s'], 1, sqrt)
df_data_code$Qm3s = sqrt(df_data_code$Qm3s)
}
df_data_code = df_data[df_data$code == code,]
maxQ = max(df_data_code$Qm3s, na.rm=TRUE)
power = nchar(as.character(as.integer(maxQ))) - 1
dbrk = 10^power
if (norm) {
df_data_code$Qm3s = df_data_code$Qm3s / dbrk
maxQ = max(df_data_code$Qm3s, na.rm=TRUE)
dbrk = 1
}
dDate = df_data_code$Date[length(df_data_code$Date)] -
df_data_code$Date[1]
......@@ -219,11 +231,19 @@ time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day,
color='cornflowerblue')
}}
if (norm) {
p = p +
ylab(bquote('dbit ['*m^{3}*'.'*s^{-1}*'] x'~10^{.(as.character(power))}))
} else {
p = p +
ylab(expression(paste('dbit [', m^{3}, '.',
s^{-1}, ']', sep='')))
}
p = p +
# ggtitle(paste(variable, 'station',
# as.character(code), sep=' ')) +
ylab(expression(paste('dbit [', m^{3}, '.',
s^{-1}, ']', sep=''))) +
xlab('date') +
scale_x_date(date_breaks=paste(as.character(datebreak),
'year', sep=' '),
......@@ -235,28 +255,23 @@ time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day,
x=as.Date(as.numeric(max(df_data_code$Date))*0.9),
y=max(df_data_code$Qm3s, na.rm=TRUE)*1.05,
label=type)
if (type == 'sqrt') {
if (type == 'sqrt') {
p = p +
scale_y_continuous(breaks=seq(0, 100, 10),
minor_breaks=seq(0, 100, 5),
limits=c(0,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
scale_y_continuous(breaks=seq(0, maxQ*10, dbrk),
# minor_breaks=seq(0, maxQ*10, dbrk/2),
limits=c(0, maxQ*1.1),
expand=c(0, 0))
} else if (type == 'time') {
p = p +
scale_y_continuous(breaks=seq(0, 10000, 1000),
minor_breaks=seq(0, 10000, 500),
limits=c(0,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
scale_y_continuous(breaks=seq(0, maxQ*10, dbrk),
# minor_breaks=seq(0, maxQ*10, dbrk/2),
limits=c(0, maxQ*1.1),
expand=c(0, 0))
} else {
p = p +
scale_y_continuous(limits=c(0,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
scale_y_continuous(limits=c(0, maxQ*1.1),
expand=c(0, 0))
}
......
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