From 32a3c9e0e90e8c8f372f493e7c724b81254b637e Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Thu, 29 Aug 2024 10:35:55 +0200
Subject: [PATCH] fix: correct 'plot.OutputsModel' zoom when 'IndPeriod_Plot'
 does not start to 1 Refs: #192

---
 R/plot.OutputsModel.R | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R
index 139db9c..a5516cc 100644
--- a/R/plot.OutputsModel.R
+++ b/R/plot.OutputsModel.R
@@ -19,10 +19,11 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
 
   ## index time series
   if (!is.null(IndPeriod_Plot)) {
-    if (length(IndPeriod_Plot) == 0) {
+    if (length(IndPeriod_Plot) == 0 || any(IndPeriod_Plot <= 0)) {
       IndPeriod_Plot <- seq_along(OutputsModel$DatesR)
+      warning('IndPeriod_Plot')
     }
-    IndPeriod_Plot <- seq_along(IndPeriod_Plot)
+    # IndPeriod_Plot <- seq_along(IndPeriod_Plot)
     OutputsModel <- .IndexOutputsModel(OutputsModel, IndPeriod_Plot)
     Qobs <- Qobs[IndPeriod_Plot]
   } else {
-- 
GitLab