From a8066a15cb47f325ed75bafabc3e1dfdac4e1079 Mon Sep 17 00:00:00 2001
From: ldam <ldam@passcal.nmt.edu>
Date: Tue, 19 Sep 2023 12:15:01 -0600
Subject: [PATCH] plot zero value in different color that is spesifized in DB
 as Z:color

---
 .../view/plotting/plotting_widget/plotting.py | 33 ++++++++++++++-----
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting.py b/sohstationviewer/view/plotting/plotting_widget/plotting.py
index ee6f5f417..d328fe3fa 100644
--- a/sohstationviewer/view/plotting/plotting_widget/plotting.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting.py
@@ -309,9 +309,10 @@ class Plotting:
         """
         Plot lines with dots at the data points. Colors of dot and lines are
         defined in valueColors in database.
-        Ex: L:G|D:W  means
+        Ex: L:G|D:W|Z:C  means
             Lines are plotted with color G
             Dots are plotted with color W
+            Additional dot with value Zero in color C (for channel GPS Lk/Unlk)
         If D is not defined, dots won't be displayed.
         If L is not defined, lines will be plotted with color G
         Color codes are defined in colorSettings
@@ -354,20 +355,40 @@ class Plotting:
             has_dot = True
         else:
             d_color = l_color
+        if 'Z' in colors:
+            z_color = colors['Z']
 
         if chan_id == 'GPS Lk/Unlk':
             sample_no_list = []
             ax.x_bottom = x_list[0][np.where(y_list[0] == -1)[0]]
             sample_no_list.append(ax.x_bottom.size)
-            sample_no_list.append(None)
+            ax.x_center = x_list[0][np.where(y_list[0] == 0)[0]]
+            sample_no_list.append(ax.x_center.size)
             ax.x_top = x_list[0][np.where(y_list[0] == 1)[0]]
             sample_no_list.append(ax.x_top.size)
-            sample_no_colors = [clr[d_color], None, clr[d_color]]
-            sample_no_pos = [0.05, None, 0.95]
+            sample_no_colors = [clr[d_color], clr[z_color], clr[d_color]]
+            sample_no_pos = [0.05, 0.5, 0.95]
+            top_bottom_index = np.where(y_list[0] != 0)[0]
+
+            # for plotting top & bottom
+            x_list = [x_list[0][top_bottom_index]]
+            y_list = [y_list[0][top_bottom_index]]
+
+            ax.myPlot = ax.plot(ax.x_center, [0] * ax.x_center.size,
+                                marker='s',
+                                markersize=1.5,
+                                linestyle='',
+                                zorder=constants.Z_ORDER['DOT'],
+                                mfc=clr[z_color],
+                                mec=clr[z_color],
+                                picker=True, pickradius=3)
         else:
             sample_no_list = [None, sum([len(x) for x in x_list]), None]
             sample_no_colors = [None, clr[d_color], None]
             sample_no_pos = [None, 0.5, None]
+            ax.x_center = x_list[0]
+            ax.y_list = y_list[0]
+
         self.plotting_axes.set_axes_info(
             ax, sample_no_list=sample_no_list,
             sample_no_colors=sample_no_colors,
@@ -395,10 +416,6 @@ class Plotting:
                                     mec=clr[d_color],
                                     picker=True, pickradius=3)
 
-        if chan_id != 'GPS Lk/Unlk':
-            ax.x_center = x_list[0]
-            ax.y_list = y_list[0]
-
         ax.chan_db_info = chan_db_info
         return ax
 
-- 
GitLab