From 3fcd4f00683919e28529ad02988599ad2b1a4c79 Mon Sep 17 00:00:00 2001
From: ldam <ldam@passcal.nmt.edu>
Date: Wed, 23 Aug 2023 14:40:31 -0600
Subject: [PATCH] recalculate total points for plot_time_dots,
 plot_multi_color_dots and plot_up_down_dots

---
 .../plotting_widget/plotting_widget.py        | 24 ++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
index 8a15edf52..a516bafce 100755
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
@@ -2,6 +2,7 @@
 Class of which object is used to plot data
 """
 from typing import List, Optional, Union
+import numpy as np
 import matplotlib.text
 from matplotlib import pyplot as pl
 from matplotlib.transforms import Bbox
@@ -570,8 +571,11 @@ class PlottingWidget(QtWidgets.QScrollArea):
                 new_max_y = None
                 if hasattr(ax, 'x_list'):
                     if not hasattr(ax, 'y_list'):
-                        # dotForTime plots have attribute 'x_list' but not
-                        # 'y_list'
+                        # plot_time_dots and plot_multi_color_dots
+                        x = ax.x_list[0]
+                        new_x_indexes = np.where(
+                            (x >= self.min_x) & (x <= self.max_x))[0]
+                        ax.center_total_point_lbl.set_text(new_x_indexes.size)
                         continue
                     total_points = 0
                     tr_min_ys = []
@@ -591,16 +595,14 @@ class PlottingWidget(QtWidgets.QScrollArea):
                         new_min_y = min(tr_min_ys)
                         new_max_y = max(tr_max_ys)
                     ax.center_total_point_lbl.set_text(total_points)
-                elif hasattr(ax, 'x'):
-                    total_points = len(ax.x)
-                    if hasattr(ax, 'y') and len(ax.y) > 0:
-                        new_min_y = min(ax.y)
-                        new_max_y = max(ax.y)
-                    ax.center_total_point_lbl.set_text(total_points)
                 else:
-                    # for case of having top and bottom total points
-                    ax.bottom_total_point_lbl.set_text(len(ax.x0))
-                    ax.top_total_point_lbl.set_text(len(ax.x1))
+                    # plot_up_down_dots
+                    new_x0_indexes = np.where(
+                        (ax.x0 >= self.min_x) & (ax.x0 <= self.max_x))[0]
+                    ax.bottom_total_point_lbl.set_text(new_x0_indexes.size)
+                    new_x1_indexes = np.where(
+                        (ax.x1 >= self.min_x) & (ax.x1 <= self.max_x))[0]
+                    ax.top_total_point_lbl.set_text(new_x1_indexes.size)
 
                 if new_min_y is not None:
                     self.plotting_axes.set_axes_ylim(
-- 
GitLab