From 98d8ea9a69871a068efcba7f86fc5b0e27ee9596 Mon Sep 17 00:00:00 2001
From: ldam <ldam@passcal.nmt.edu>
Date: Tue, 19 Sep 2023 13:59:56 -0600
Subject: [PATCH] remove linkedChan, adjust position of title and sub title

---
 sohstationviewer/database/extract_data.py     |   2 +-
 .../multi_threaded_plotting_widget.py         |   9 -
 .../view/plotting/plotting_widget/plotting.py | 207 +++++++-----------
 .../plotting/plotting_widget/plotting_axes.py |  55 ++---
 .../view/plotting/state_of_health_widget.py   |  44 +---
 .../view/plotting/waveform_dialog.py          |   2 +-
 tests/database/test_extract_data.py           |   8 -
 7 files changed, 106 insertions(+), 221 deletions(-)

diff --git a/sohstationviewer/database/extract_data.py b/sohstationviewer/database/extract_data.py
index 6bd35f453..461358d76 100755
--- a/sohstationviewer/database/extract_data.py
+++ b/sohstationviewer/database/extract_data.py
@@ -28,7 +28,7 @@ def get_chan_plot_info(org_chan_id: str, data_type: str,
     # Seeing as we only need one of these columns for a color mode, we only
     # pull the needed valueColors column from the database.
     value_colors_column = 'valueColors' + color_mode
-    o_sql = (f"SELECT channel, plotType, height, unit, linkedChan,"
+    o_sql = (f"SELECT channel, plotType, height, unit,"
              f" convertFactor, label, fixPoint, "
              f"{value_colors_column} AS valueColors "
              f"FROM Channels as C, Parameters as P")
diff --git a/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py
index c79ceceb2..cbfbc4a8d 100644
--- a/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py
+++ b/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py
@@ -155,9 +155,6 @@ class MultiThreadedPlottingWidget(PlottingWidget):
                    f"{', '.join( not_plot_chans)}")
             self.processing_log.append((msg, LogType.WARNING))
 
-        if is_plotting_data1:
-            self.move_soh_channels_with_link_to_the_end(chan_order)
-
         for chan_id in chan_order:
             if 'chan_db_info' not in plotting_data[chan_id]:
                 continue
@@ -170,12 +167,6 @@ class MultiThreadedPlottingWidget(PlottingWidget):
             channel_processor.finished.connect(self.process_channel)
             channel_processor.stopped.connect(self.has_stopped)
 
-    def move_soh_channels_with_link_to_the_end(self, chan_order):
-        """
-        This only need for soh channels
-        """
-        pass
-
     def plot_channels(self, d_obj, key, start_tm, end_tm, time_ticks_total,
                       pref_order=[]):
         """
diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting.py b/sohstationviewer/view/plotting/plotting_widget/plotting.py
index d328fe3fa..88fb9db2b 100644
--- a/sohstationviewer/view/plotting/plotting_widget/plotting.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting.py
@@ -1,5 +1,7 @@
 # class with all plotting functions
+from typing import Dict, Optional
 import numpy as np
+from matplotlib.axes import Axes
 
 from sohstationviewer.controller.util import get_val
 from sohstationviewer.controller.plotting_data import get_masspos_value_colors
@@ -40,8 +42,8 @@ class Plotting:
         ax.chan_db_info = None
         return ax
 
-    def plot_multi_color_dots(self, c_data, chan_db_info, chan_id,
-                              ax, linked_ax):
+    def plot_multi_color_dots(
+            self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes:
         """
         plot scattered dots with colors defined by valueColors in database:
             Ex: *:W  means everything with white color
@@ -53,24 +55,16 @@ class Plotting:
         Color codes are defined in colorSettings and limitted in 'valColRE'
             in dbSettings.py
 
-        :param c_data: dict - data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            soh_data[key][chan_id]
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :return ax: axes of the channel
         """
-        if linked_ax is not None:
-            ax = linked_ax
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h,
-                has_min_max_lines=False)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h,
+            has_min_max_lines=False)
 
         x = []
         prev_val = -constants.HIGHEST_INT
@@ -117,14 +111,14 @@ class Plotting:
             ax, sample_no_list=[None, total_samples, None],
             sample_no_colors=sample_no_colors,
             sample_no_pos=[None, 0.5, None],
-            chan_db_info=chan_db_info, linked_ax=linked_ax)
+            chan_db_info=chan_db_info)
 
         ax.x_center = c_data['times'][0]
         ax.chan_db_info = chan_db_info
         return ax
 
-    def plot_tri_colors(self, c_data, chan_db_info, chan_id,
-                        ax, linked_ax):
+    def plot_tri_colors(
+            self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes:
         """
         Plot 3 different values in 3 lines with 3 different colors according
         to valueColors:
@@ -132,27 +126,19 @@ class Plotting:
                 value = -1  => plot on line y=-1 with M color
                 value = 0   => plot on line y=0 with R color
                 value = 1 => plot on line y=1 with Y color
-        Color codes are defined in colorSettings and limitted in 'valColRE'
+        Color codes are defined in colorSettings and limited in 'valColRE'
             in dbSettings.py
 
         :param c_data: data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            soh_data[key][chan_id]
-        :param chan_db_info: dict - info of channel from DB
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
         :param chan_id: name of channel
-        :param ax: axes to draw plot of channel
-        :param linked_ax:  axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
         :return ax: axes of the channel
         """
-        if linked_ax is not None:
-            ax = linked_ax
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h,
-                has_min_max_lines=False)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h,
+            has_min_max_lines=False)
 
         value_colors = chan_db_info['valueColors'].split('|')
 
@@ -189,38 +175,31 @@ class Plotting:
             ax, sample_no_list=total_sample_list,
             sample_no_colors=sample_no_colors,
             sample_no_pos=[0.05, 0.5, 0.95],
-            chan_db_info=chan_db_info, linked_ax=linked_ax)
+            chan_db_info=chan_db_info)
 
         ax.chan_db_info = chan_db_info
         return ax
 
-    def plot_up_down_dots(self, c_data, chan_db_info, chan_id, ax, linked_ax):
+    def plot_up_down_dots(
+            self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes:
         """
         Plot channel with 2 different values, one above, one under center line.
         Each value has corresponding color defined in valueColors in database.
         Ex: 1:Y|0:R  means
             value == 1 => plot above center line with Y color
             value == 0 => plot under center line with R color
-        Color codes are defined in colorSettings
+        Color codes are defined in colorSettings.
 
-        :param c_data: dict - data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            soh_data[key][chan_id]
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :return ax: axes of the channel
         """
-        if linked_ax is not None:
-            ax = linked_ax
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h,
-                has_min_max_lines=False)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h,
+            has_min_max_lines=False)
 
         val_cols = chan_db_info['valueColors'].split('|')
         # up/down has 2 values: 0, 1 which match with index of points_list
@@ -252,7 +231,7 @@ class Plotting:
             sample_no_list=[len(points_list[0]), None, len(points_list[1])],
             sample_no_colors=[clr[colors[0]], None, clr[colors[1]]],
             sample_no_pos=[0.25, None, 0.75],
-            chan_db_info=chan_db_info, linked_ax=linked_ax)
+            chan_db_info=chan_db_info)
 
         # x_bottom, x_top are the times of data points to be displayed at
         # bottom or top of the plot
@@ -262,27 +241,23 @@ class Plotting:
         ax.chan_db_info = chan_db_info
         return ax
 
-    def plot_time_dots(self, c_data, chan_db_info, chan_id, ax, linked_ax):
+    def plot_time_dots(
+            self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes:
         """
         Plot times only
         :param c_data: dict - data of the channel which includes down-sampled
             data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
             soh_data[key][chan_id]
 
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :return ax: axes of the channel
         """
-        if linked_ax is not None:
-            ax = linked_ax
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h)
 
         color = 'W'
         if chan_db_info['valueColors'] not in [None, 'None', '']:
@@ -293,7 +268,7 @@ class Plotting:
             ax, sample_no_list=[None, total_x, None],
             sample_no_colors=[None, clr[color], None],
             sample_no_pos=[None, 0.5, None],
-            chan_db_info=chan_db_info, linked_ax=linked_ax)
+            chan_db_info=chan_db_info)
 
         for x in x_list:
             ax.plot(x, [0] * len(x), marker='s', markersize=1.5,
@@ -304,8 +279,9 @@ class Plotting:
         ax.chan_db_info = chan_db_info
         return ax
 
-    def plot_lines_dots(self, c_data, chan_db_info, chan_id,
-                        ax, linked_ax, info=''):
+    def plot_lines_dots(
+        self, c_data: Dict, chan_db_info: Dict, chan_id: str, info: str = ''
+    ) -> Axes:
         """
         Plot lines with dots at the data points. Colors of dot and lines are
         defined in valueColors in database.
@@ -317,26 +293,17 @@ class Plotting:
         If L is not defined, lines will be plotted with color G
         Color codes are defined in colorSettings
 
-        :param c_data: dict - data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            soh_data[key][chan_id] or DataTypeModel.__init__.
-            waveform_data[key]['read_data'][chan_id] for waveform data
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :param info: str - additional info to be displayed on sub-title under
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :param info: additional info to be displayed on sub-title under
             main-title
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :return ax: axes of the channel
         """
-        if linked_ax is not None:
-            ax = linked_ax
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h)
 
         x_list, y_list = c_data['times'], c_data['data']
 
@@ -355,10 +322,9 @@ class Plotting:
             has_dot = True
         else:
             d_color = l_color
-        if 'Z' in colors:
-            z_color = colors['Z']
 
         if chan_id == 'GPS Lk/Unlk':
+            z_color = colors['Z']
             sample_no_list = []
             ax.x_bottom = x_list[0][np.where(y_list[0] == -1)[0]]
             sample_no_list.append(ax.x_bottom.size)
@@ -382,6 +348,7 @@ class Plotting:
                                 mfc=clr[z_color],
                                 mec=clr[z_color],
                                 picker=True, pickradius=3)
+            info = "GPS Clock Power"
         else:
             sample_no_list = [None, sum([len(x) for x in x_list]), None]
             sample_no_colors = [None, clr[d_color], None]
@@ -394,7 +361,7 @@ class Plotting:
             sample_no_colors=sample_no_colors,
             sample_no_pos=sample_no_pos,
             chan_db_info=chan_db_info,
-            info=info, y_list=y_list, linked_ax=linked_ax)
+            info=info, y_list=y_list)
 
         for x, y in zip(x_list, y_list):
             if not has_dot and sample_no_list[1] > 1:
@@ -419,46 +386,37 @@ class Plotting:
         ax.chan_db_info = chan_db_info
         return ax
 
-    def plot_lines_s_rate(self, c_data, chan_db_info, chan_id, ax, linked_ax):
+    def plot_lines_s_rate(
+            self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes:
         """
         Plot line only for waveform data channel (seismic data). Sample rate
         unit will be displayed
 
-        :param c_data: dict - data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            waveform_data[key]['read_data'][chan_id]
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :return ax: axes of the channel
         """
         if c_data['samplerate'] >= 1.0:
             info = "%dsps" % c_data['samplerate']
         else:
             info = "%gsps" % c_data['samplerate']
-        return self.plot_lines_dots(c_data, chan_db_info, chan_id,
-                                    ax, linked_ax, info=info)
+        return self.plot_lines_dots(c_data, chan_db_info, chan_id, info=info)
 
-    def plot_lines_mass_pos(self, c_data, chan_db_info, chan_id,
-                            ax, linked_ax):
+    def plot_lines_mass_pos(
+        self, c_data: Dict, chan_db_info: Dict, chan_id: str
+    ) -> Optional[Axes]:
         """
         Plot multi-color dots with grey line for mass position channel.
         Use get_masspos_value_colors() to get value_colors map based on
             Menu - MP Coloring selected from Main Window.
 
-        :param c_data: dict - data of the channel which includes down-sampled
-            data in keys 'times' and 'data'. Refer to DataTypeModel.__init__.
-            mass_pos_data[key][chan_id]
-        :param chan_db_info: dict - info of channel from DB
-        :param chan_id: str - name of channel
-        :param ax: matplotlib.axes.Axes - axes to draw plot of channel
-        :param linked_ax: matplotlib.axes.Axes/None - axes of another channel
-            linked to this channel => both channels' will be plotted on the
-            same axes
-        :return ax: matplotlib.axes.Axes - axes of the channel
+        :param c_data: data of the channel which includes down-sampled
+            (if needed) data in keys 'times' and 'data'.
+        :param chan_db_info: info of channel from DB
+        :param chan_id: name of channel
+        :return ax: axes of the channel
         """
         value_colors = get_masspos_value_colors(
             self.main_window.mass_pos_volt_range_opt, chan_id,
@@ -468,10 +426,9 @@ class Plotting:
         if value_colors is None:
             return
 
-        if ax is None:
-            plot_h = self.plotting_axes.get_height(chan_db_info['height'])
-            ax = self.plotting_axes.create_axes(
-                self.parent.plotting_bot, plot_h)
+        plot_h = self.plotting_axes.get_height(chan_db_info['height'])
+        ax = self.plotting_axes.create_axes(
+            self.parent.plotting_bot, plot_h)
 
         x_list, y_list = c_data['times'], c_data['data']
         total_x = sum([len(x) for x in x_list])
diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
index f2eb555f9..538cebc4e 100644
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py
@@ -167,7 +167,7 @@ class PlottingAxes:
             return
         return ax.text(
             1.005, pos_y,
-            sample_no,
+            str(sample_no),
             horizontalalignment='left',
             verticalalignment='center',
             rotation='horizontal',
@@ -183,8 +183,7 @@ class PlottingAxes:
                       label: Optional[str] = None,
                       info: str = '',
                       y_list: Optional[np.ndarray] = None,
-                      chan_db_info: Optional[Dict] = None,
-                      linked_ax: Optional[Axes] = None):
+                      chan_db_info: Optional[Dict] = None):
         """
         Draw plot's title, sub title, sample total label, center line, y labels
         for a channel.
@@ -197,25 +196,15 @@ class PlottingAxes:
         :param label: title of the plot. If None, show chan_db_info['label']
         :param info: additional info to show in sub title which is
             smaller and under title on the left side
-        :param y: y values of the channel for min/max labels, min/max lines
+        :param y_list: y values of the channel for min/max labels, lines
         :param chan_db_info: info of channel from database
-        :param linked_ax:
-            if linked_ax is None, this is a main channel, label of channel will
-                be displayed with title's format, on top right of plot.
-            if linked_ax is not None, this is a channel using main channel's
-                axes, label of channel will be displayed with sub title's
-                format - under main title.
         """
         if label is None:
             label = chan_db_info['label']
-
-        title_ver_alignment = 'center'
-        # set info in subtitle under title
-        if linked_ax is not None:
-            info = label
+        pos_y = 0.4
         if info != '':
             ax.text(
-                -0.15, 0.2,
+                -0.15, 0.4,
                 info,
                 horizontalalignment='left',
                 verticalalignment='top',
@@ -224,23 +213,20 @@ class PlottingAxes:
                 color=self.parent.display_color['sub_basic'],
                 size=self.parent.font_size
             )
-            title_ver_alignment = 'top'
-
-        if linked_ax is None:
-            # set title on left side
-            color = self.parent.display_color['plot_label']
-            if label.startswith("DEFAULT"):
-                color = self.parent.display_color["warning"]
-            ax.text(
-                -0.15, 0.6,
-                label,
-                horizontalalignment='left',
-                verticalalignment=title_ver_alignment,
-                rotation='horizontal',
-                transform=ax.transAxes,
-                color=color,
-                size=self.parent.font_size + 2 * self.parent.ratio_w
-            )
+            pos_y = 0.6
+        # set title on left side
+        color = self.parent.display_color['plot_label']
+        if label.startswith("DEFAULT"):
+            color = self.parent.display_color["warning"]
+        ax.text(
+            -0.15, pos_y,
+            label,
+            horizontalalignment='left',
+            rotation='horizontal',
+            transform=ax.transAxes,
+            color=color,
+            size=self.parent.font_size + 2 * self.parent.ratio_w
+        )
 
         # set samples' total on right side
         # bottom
@@ -253,9 +239,6 @@ class PlottingAxes:
         ax.top_total_point_lbl = self.create_sample_no_label(
             ax, sample_no_pos[2], sample_no_list[2], sample_no_colors[2])
 
-        if linked_ax is not None:
-            ax.set_yticks([])
-            return
         if y_list is None:
             # draw center line
             ax.plot([self.parent.min_x, self.parent.max_x],
diff --git a/sohstationviewer/view/plotting/state_of_health_widget.py b/sohstationviewer/view/plotting/state_of_health_widget.py
index fe34d3a5f..29945f3af 100644
--- a/sohstationviewer/view/plotting/state_of_health_widget.py
+++ b/sohstationviewer/view/plotting/state_of_health_widget.py
@@ -68,46 +68,8 @@ class SOHWidget(MultiThreadedPlottingWidget):
             return
         chan_db_info = c_data['chan_db_info']
         plot_type = chan_db_info['plotType']
-
-        linked_ax = None
-        try:
-            if chan_db_info['linkedChan'] not in [None, 'None', '']:
-                linked_ax = self.plotting_data1[chan_db_info[
-                    'linkedChan']]['ax']
-        except KeyError:
-            # linkedChan not point to an actual channel
-            # which is when the channel in linkedChan doesn't have data
-            # or the channel with likedChan is plotted first
-            # (the later is prevented by
-            # move_soh_channels_with_link_to_the_end())
-            pass
         ax = getattr(self.plotting, plot_functions[plot_type][1])(
-            c_data, chan_db_info, chan_id, None, linked_ax)
+            c_data, chan_db_info, chan_id)
         c_data['ax'] = ax
-        if linked_ax is None:
-            # to prevent same ax is appended to self.axes twice when there is
-            # linkedChan for the channel
-            ax.chan = chan_id
-            self.axes.append(ax)
-
-    def move_soh_channels_with_link_to_the_end(self, chan_order):
-        """
-        In order to plot a channel (channel A) that is linked with another
-        channel (channel B), we need to plot B before we plot A. Because the
-        order of the channel in the data is not predetermined, we need to
-        manually move A to the end of chan_order. This is, of course,
-        assuming that channel link is at most one level deep.
-        """
-        channels_to_move = []
-
-        for channel, chan_data in self.plotting_data1.items():
-            try:
-                linked_channel = chan_data['chan_db_info']['linkedChan']
-                if linked_channel not in ['', 'None', None]:
-                    chan_order.remove(channel)
-                    channels_to_move.append(channel)
-            except KeyError:
-                continue
-
-        for channel in channels_to_move:
-            chan_order.append(channel)
+        ax.chan = chan_id
+        self.axes.append(ax)
diff --git a/sohstationviewer/view/plotting/waveform_dialog.py b/sohstationviewer/view/plotting/waveform_dialog.py
index 23a4c0283..d22354a5c 100755
--- a/sohstationviewer/view/plotting/waveform_dialog.py
+++ b/sohstationviewer/view/plotting/waveform_dialog.py
@@ -50,7 +50,7 @@ class WaveformWidget(MultiThreadedPlottingWidget):
 
         # refer to doc string for mass_pos_data to know the reason for 'ax_wf'
         ax = getattr(self.plotting, plot_functions[plot_type][1])(
-            c_data, chan_db_info, chan_id, None, None)
+            c_data, chan_db_info, chan_id)
         c_data['ax_wf'] = ax
         ax.chan = chan_id
         self.axes.append(ax)
diff --git a/tests/database/test_extract_data.py b/tests/database/test_extract_data.py
index 268a6b0a1..b2931355a 100644
--- a/tests/database/test_extract_data.py
+++ b/tests/database/test_extract_data.py
@@ -21,7 +21,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                            'plotType': 'upDownDots',
                            'height': 2,
                            'unit': '',
-                           'linkedChan': None,
                            'convertFactor': 1,
                            'label': 'SOH/Data Def',
                            'fixPoint': 0,
@@ -35,7 +34,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                                'plotType': 'linesMasspos',
                                'height': 4,
                                'unit': 'V',
-                               'linkedChan': None,
                                'convertFactor': 0.1,
                                'label': 'VM1-MassPos',
                                'fixPoint': 1,
@@ -48,7 +46,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                                'plotType': 'linesMasspos',
                                'height': 4,
                                'unit': 'V',
-                               'linkedChan': None,
                                'convertFactor': 1,
                                'label': 'MassPos1',
                                'fixPoint': 1,
@@ -62,7 +59,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                                'plotType': 'linesSRate',
                                'height': 8,
                                'unit': '',
-                               'linkedChan': None,
                                'convertFactor': 1,
                                'label': 'DS2',
                                'fixPoint': 0,
@@ -75,7 +71,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                                'plotType': 'linesSRate',
                                'height': 8,
                                'unit': '',
-                               'linkedChan': None,
                                'convertFactor': 1,
                                'label': 'LHE-EW',
                                'fixPoint': 0,
@@ -93,7 +88,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                            'plotType': 'linesDots',
                            'height': 2,
                            'unit': '',
-                           'linkedChan': None,
                            'convertFactor': 1,
                            'label': 'DEFAULT-Bad Channel ID',
                            'fixPoint': 0,
@@ -106,7 +100,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                            'plotType': 'linesDots',
                            'height': 3,
                            'unit': 'us',
-                           'linkedChan': None,
                            'convertFactor': 1,
                            'label': 'LCE-PhaseError',
                            'fixPoint': 0,
@@ -126,7 +119,6 @@ class TestGetChanPlotInfo(unittest.TestCase):
                            'plotType': 'linesDots',
                            'height': 2,
                            'unit': '',
-                           'linkedChan': None,
                            'convertFactor': 1,
                            'label': None,  # Change for each test case
                            'fixPoint': 0,
-- 
GitLab