From 6b5067b1ac09a7b6fd6a93f874b1586a926be01c Mon Sep 17 00:00:00 2001
From: ldam <ldam@passcal.nmt.edu>
Date: Wed, 23 Aug 2023 12:49:33 -0600
Subject: [PATCH] set_axis_info: remove clear labels at the beginning because
 with lim for zooming, we don't recreate axis for each zoom; add labels for
 total of data point as attribute for ax to do set_text when there are changes
 for the total

---
 .../view/plotting/plotting_widget/plotting_axes.py  | 13 +++----------
 .../plotting/plotting_widget/plotting_widget.py     |  4 ++--
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
index 9becc2273..259771507 100644
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
@@ -184,13 +184,6 @@ class PlottingAxes:
                 axes, label of channel will be displayed with sub title's
                 format - under main title.
         """
-        if linked_ax is None:
-            # clear all texts before recreated.
-            # But not clear when this is a linked_ax because texts are already
-            # cleared with ax, if clear with linked_ax all info of ax won't be
-            # displayed
-            ax.texts.clear()
-
         if label is None:
             label = chan_db_info['label']
 
@@ -229,7 +222,7 @@ class PlottingAxes:
 
         # set samples' total on right side
         if len(sample_no_list) == 1:
-            ax.sampleLbl = ax.text(
+            ax.center_total_points_lbl = ax.text(
                 1.005, 0.5,
                 sample_no_list[0],
                 horizontalalignment='left',
@@ -247,7 +240,7 @@ class PlottingAxes:
             # and won't be changed in set_lim, then don't need to assign a
             # variable for it.
             # bottom
-            ax.text(
+            ax.bottom_total_points_lbl = ax.text(
                 1.005, sample_no_pos[0],
                 sample_no_list[0],
                 horizontalalignment='left',
@@ -258,7 +251,7 @@ class PlottingAxes:
                 size=self.parent.font_size
             )
             # top
-            ax.text(
+            ax.top_total_points_lbl = ax.text(
                 1.005, sample_no_pos[1],
                 sample_no_list[1],
                 horizontalalignment='left',
diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
index 77a60ce71..a26463af3 100755
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
@@ -557,7 +557,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
                                                                self.max_x)]
 
                 # reset total of samples on the right
-                self.gap_bar.sampleLbl.set_text(len(new_gaps))
+                self.gap_bar.center_total_points_lbl.set_text(len(new_gaps))
 
         for ax in self.axes:
             if hasattr(ax, 'x') and ax.x is None:
@@ -596,7 +596,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
                         new_min_y = min(ax.y)
                         new_max_y = max(ax.y)
                 try:
-                    ax.sampleLbl.set_text(total_points)
+                    ax.center_total_points_lbl.set_text(total_points)
                 except AttributeError:
                     # for case of having top and bottom total points
                     # which is for RT130's SOH only, trust in total point
-- 
GitLab