Skip to content
Snippets Groups Projects
Commit 0f8160f8 authored by Lan Dam's avatar Lan Dam
Browse files

simplify drawing sample numbers' labels to give plotting function have more control on this

parent c4570703
No related branches found
No related tags found
2 merge requests!180Make GPS Lk/Unlk and GPS Clock Power to plot in the same channel,!179Give the option to plot three lines for different values and colors
......@@ -12,7 +12,6 @@ from sohstationviewer.controller.plotting_data import (
get_time_ticks, get_unit_bitweight, get_disk_size_format)
from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import clr
class PlottingAxes:
......@@ -154,10 +153,32 @@ class PlottingAxes:
ax.patch.set_alpha(0)
return ax
def create_sample_no_label(self, ax: Axes, pos_y: float,
sample_no: int, color: str) -> None:
"""
Create label to display sample number
:param ax: the axes of the label
:param pos_y: vertical position for the label
:param sample_no: total of samples
:param color: color of the text in the label
"""
if sample_no is None:
return
return ax.text(
1.005, pos_y,
sample_no,
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=color,
size=self.parent.font_size
)
def set_axes_info(self, ax: Axes,
sample_no_list: List[int],
sample_no_colors: List[str] = [clr['W'], clr['W']],
sample_no_pos: List[float] = [0.05, 0.95],
sample_no_colors: List[str],
sample_no_pos: List[float],
label: Optional[str] = None,
info: str = '',
y_list: Optional[np.ndarray] = None,
......@@ -221,48 +242,16 @@ class PlottingAxes:
)
# set samples' total on right side
if len(sample_no_list) == 1:
# center_total_point_lbl: The label to display total number of data
# points for plots whose ax has attribute x_list.
# The plotTypes that use this label are linesDot, linesSRate,
# linesMassPos, dotForTime, multiColorDot
ax.center_total_point_lbl = ax.text(
1.005, 0.5,
sample_no_list[0],
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=sample_no_colors[0],
size=self.parent.font_size
)
else:
# bottom_total_point_lbl, top_total_point_lbl are label to diplay
# total number of data points which are splitted into top
# and bottom. The ax needs to include attributes x_bottom and x_top
# The plotTypes that use these labels are upDownDots and linesDot
# with channel='GPS Lk/Unlk'
ax.bottom_total_point_lbl = ax.text(
1.005, sample_no_pos[0],
sample_no_list[0],
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=sample_no_colors[0],
size=self.parent.font_size
)
# top
ax.top_total_point_lbl = ax.text(
1.005, sample_no_pos[1],
sample_no_list[1],
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=sample_no_colors[1],
size=self.parent.font_size
)
# bottom
ax.bottom_total_point_lbl = self.create_sample_no_label(
ax, sample_no_pos[0], sample_no_list[0], sample_no_colors[0])
# center
ax.center_total_point_lbl = self.create_sample_no_label(
ax, sample_no_pos[1], sample_no_list[1], sample_no_colors[1])
# top
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment