From 0e2c036f9f3be939242ac4a3276bb7213566b31b Mon Sep 17 00:00:00 2001
From: "louis.heraut" <louis.heraut@inrae.fr>
Date: Tue, 30 Nov 2021 15:25:26 +0100
Subject: [PATCH] Aes for trend name

---
 plotting/panel.R | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plotting/panel.R b/plotting/panel.R
index b939c2b..87b19e3 100644
--- a/plotting/panel.R
+++ b/plotting/panel.R
@@ -174,6 +174,8 @@ time_panel = function (df_data_code, df_trend_code, type, p_threshold=0.1, missR
         
         ltype = c('solid', 'dashed', 'dotted', 'twodash')
         lty = c('solid', '22')
+        
+        ii = 0
         for (i in 1:nPeriod) {
 
             df_trend_code_per = 
@@ -182,6 +184,8 @@ time_panel = function (df_data_code, df_trend_code, type, p_threshold=0.1, missR
 
             if (df_trend_code_per$p <= p_threshold) {
 
+                ii = ii + 1
+
                 iStart = which.min(abs(df_data_code$Date - Start[i]))
                 iEnd = which.min(abs(df_data_code$Date - End[i]))
 
@@ -210,11 +214,11 @@ time_panel = function (df_data_code, df_trend_code, type, p_threshold=0.1, missR
                 codeDate = df_data_code$Date
                 codeQ = df_data_code$Qm3s
                 
-                x = gpct(3, codeDate, shift=TRUE)
+                x = gpct(2, codeDate, shift=TRUE)
                 xend = x + gpct(3, codeDate)
                
                 dy = gpct(5, codeQ, ref=0)
-                y = gpct(108, codeQ, ref=0) - (i-1)*dy
+                y = gpct(105, codeQ, ref=0) - (ii-1)*dy
 
                 xt = xend + gpct(1, codeDate)
                 label = bquote(bold(.(format(df_trend_code$trend, scientific=TRUE, digits=3)))~'['*m^{3}*'.'*s^{-1}*'.'*an^{-1}*']')
-- 
GitLab