From d1e16d0381b0f4682e8af1d66398e8407e0dd0e2 Mon Sep 17 00:00:00 2001 From: oliviermirat Date: Thu, 30 Jan 2025 09:34:41 +0800 Subject: [PATCH] fixing empty plot when no bouts detected problem --- zebrazoom/code/GUI/GUI_InitialClasses.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/zebrazoom/code/GUI/GUI_InitialClasses.py b/zebrazoom/code/GUI/GUI_InitialClasses.py index 5107a18..a3b5312 100644 --- a/zebrazoom/code/GUI/GUI_InitialClasses.py +++ b/zebrazoom/code/GUI/GUI_InitialClasses.py @@ -1749,10 +1749,25 @@ def showGraphForAllBoutsCombined(self, numWell, numPoiss, dataRef, visualization headXFinal = [] headYFinal = [] + if len(dataRef["wellPoissMouv"][numWell][numPoiss]) == 0: + try: + from zebrazoom.dataAPI.getDataPerTimeInterval import getDataPerTimeInterval + HeadPos = getDataPerTimeInterval(self.currentResultFolder, numWell, numPoiss, None, None, "HeadPos") + headXFinal.extend([HeadPos[0][0]]) + headYFinal.extend([HeadPos[0][1]]) + except Exception as e: + print(f"An error occurred: {e}") + except KeyboardInterrupt: # Allow manual interruption (CTRL+C) + print("Program interrupted by user!") + except SystemExit: + print("System exit requested!") for numMouv in range(0, len(dataRef["wellPoissMouv"][numWell][numPoiss])): headXFinal.extend(dataRef["wellPoissMouv"][numWell][numPoiss][numMouv]["HeadX"]) headYFinal.extend(dataRef["wellPoissMouv"][numWell][numPoiss][numMouv]["HeadY"]) - plt.plot(headXFinal, headYFinal) + if len(dataRef["wellPoissMouv"][numWell][numPoiss]) == 0: + plt.plot(headXFinal, headYFinal, 'o') + else: + plt.plot(headXFinal, headYFinal) if not(graphScaling): plt.xlim(0, dataRef["wellPositions"][numWell]["lengthX"]) plt.ylim(dataRef["wellPositions"][numWell]["lengthY"], 0)