From 69542f80cbfba78e105fde3f6a6090c390684ad4 Mon Sep 17 00:00:00 2001
From: Lan <ldam@passcal.nmt.edu>
Date: Fri, 5 May 2023 14:23:47 -0600
Subject: [PATCH] for fixPoint=0, round to the decimal places that can show
 differences between max and min

---
 .../plotting/plotting_widget/plotting_axes.py    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
index 940110dc3..8f604e530 100644
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
@@ -278,9 +278,9 @@ class PlottingAxes:
             ax.unit_bw = get_unit_bitweight(
                 chan_db_info, self.main_window.bit_weight_opt
             )
-            self.set_axes_ylim(ax, min_y, max_y)
+            self.set_axes_ylim(ax, min_y, max_y, chan_db_info)
 
-    def set_axes_ylim(self, ax, min_y, max_y):
+    def set_axes_ylim(self, ax, org_min_y, org_max_y, chan_db_info):
         """
         Limit y range in min_y, max_y.
         Set y tick labels at min_y, max_y
@@ -288,8 +288,16 @@ class PlottingAxes:
         :param min_y: float - minimum of y values
         :param max_y: float - maximum of y values
         """
-        min_y = round(min_y, 2)
-        max_y = round(max_y, 2)
+        min_y = round(org_min_y, 7)
+        max_y = round(org_max_y, 7)
+        if chan_db_info['fixPoint'] == 0 and org_max_y > org_min_y:
+            # if fixPoint=0, the format uses the save value created
+            # => try to round to to the point that user can see the differences
+            for dec in range(2, 8, 1):
+                min_y = round(org_min_y, dec)
+                max_y = round(org_max_y, dec)
+                if max_y > min_y:
+                    break
         if max_y > min_y:
             # There are different values for y => show yticks for min, max
             # separately
-- 
GitLab