diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting.py b/sohstationviewer/view/plotting/plotting_widget/plotting.py index f0249f0f566d7d2330ac7441c04c0acaae0ec6b0..c463998dcfc0673c90c93bfa241fa9438cb51283 100644 --- a/sohstationviewer/view/plotting/plotting_widget/plotting.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting.py @@ -100,6 +100,69 @@ class Plotting: ax.chan_db_info = chan_db_info return 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: + Ex: -1:M|0:R|1:Y means + 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' + in dbSettings.py + + :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 + """ + 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('|') + + sample_no_colors = [] + total_sample_list = [] + for vc in value_colors: + v, c = vc.split(':') + sample_no_colors.append(clr[c]) + val = get_val(v) + indexes = np.where(c_data['data'][0] == val)[0] + times = c_data['times'][0][indexes] + + # base line + ax.plot([self.parent.min_x, self.parent.max_x], + [val, val], + color=clr['r'], + linewidth=0.5, + zorder=constants.Z_ORDER['CENTER_LINE'] + ) + ax.plot(times, len(times) * [val], linestyle="", + marker='s', markersize=2, + zorder=constants.Z_ORDER['DOT'], + color=clr[c], picker=True, pickradius=3) + + total_sample_list.append(len(times)) + if val == -1: + ax.x_bottom = times + elif val == 0: + ax.x_center = times + else: + ax.x_top = times + + self.plotting_axes.set_axes_info( + 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) + + ax.chan_db_info = chan_db_info + return ax + def plot_multi_color_dots_equal_on_upper_bound( self, c_data: Dict, chan_db_info: Dict, chan_id: str) -> Axes: """