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

tps scrollbar, label's position, color, height for each

parent caab6ec0
No related branches found
No related tags found
1 merge request!136tps scrollbar, label's position, color, height for each
......@@ -352,17 +352,23 @@ class PlottingAxes:
)
)
def get_height(self, ratio, bw_plots_distance=0.0015):
def get_height(self, ratio: float, bw_plots_distance: float = 0.0015,
pixel_height: float = 19) -> float:
"""
Calculate new plot's bottom position and return plot's height.
:param ratio: float - ratio of the plot height on the BASIC_HEIGHT
:param bw_plots_distance: float - distance between plots
:return plot_h: float - height of the plot
:param ratio: ratio of the plot height on the BASIC_HEIGHT
:param bw_plots_distance: distance between plots
:param pixel_height: height of plot in pixel (
for TPS/TPS legend, height of each day row)
:return plot_h: height of the plot
"""
plot_h = constants.BASIC_HEIGHT * ratio # ratio with figure height
self.parent.plotting_bot -= plot_h + bw_plots_distance
self.parent.plotting_bot_pixel += 19 * ratio
bw_plots_distance_pixel = 3000 * bw_plots_distance
self.parent.plotting_bot_pixel += (pixel_height * ratio +
bw_plots_distance_pixel)
return plot_h
def add_ruler(self, color):
......
......@@ -89,8 +89,10 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
self.is_working = True
self.set_key = key
self.plotting_data1 = d_obj.waveform_data[key]
self.plot_total = len(self.plotting_data1)
self.plotting_bot = const.BOTTOM
self.plotting_bot_pixel = const.BOTTOM_PX
self.processed_channels = []
self.channels = []
self.tps_processors = []
......@@ -111,7 +113,7 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
title = get_title(key, self.min_x, self.max_x, self.date_mode)
self.timestamp_bar_top = self.plotting_axes.add_timestamp_bar(0.)
self.plotting_axes.set_title(title, y=0, v_align='bottom')
self.plotting_axes.set_title(title, y=5, v_align='bottom')
if self.plotting_data1 == {}:
self.is_working = False
......@@ -220,11 +222,12 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
total_days = c_data['tps_data'].shape[0]
plot_h = self.plotting_axes.get_height(
1.5 * total_days, bw_plots_distance=0.003)
total_days/2, bw_plots_distance=0.003, pixel_height=12.1)
ax = self.create_axes(self.plotting_bot, plot_h)
ax.spines[['right', 'left', 'top', 'bottom']].set_visible(False)
ax.text(
-0.1, 1.2,
f"{get_chan_label(chan_id)} {c_data['samplerate']}",
-0.12, 1,
f"{get_chan_label(chan_id)} {c_data['samplerate']}sps",
horizontalalignment='left',
verticalalignment='top',
rotation='horizontal',
......@@ -234,17 +237,17 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
)
zoom_marker1 = ax.plot(
[], [], marker='|', markersize=10,
[], [], marker='|', markersize=5,
markeredgecolor=self.display_color['zoom_marker'])[0]
self.zoom_marker1s.append(zoom_marker1)
zoom_marker2 = ax.plot(
[], [], marker='|', markersize=10,
[], [], marker='|', markersize=5,
markeredgecolor=self.display_color['zoom_marker'])[0]
self.zoom_marker2s.append(zoom_marker2)
ruler = ax.plot(
[], [], marker='s', markersize=5,
[], [], marker='s', markersize=4,
markeredgecolor=self.display_color['time_ruler'],
markerfacecolor='None')[0]
self.rulers.append(ruler)
......@@ -258,8 +261,8 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
# not draw data out of day range
color_set = self.get_color_set(y, square_counts, color_codes)
# (- dayIdx): each day is a line, increase from top to bottom
ax.scatter(x, [- dayIdx] * len(x), marker='|',
c=color_set, s=7, alpha=0.8)
ax.scatter(x, [- dayIdx] * len(x), marker='s',
c=color_set, s=3)
# extra to show highlight square
ax.set_ylim(-(c_data['tps_data'].shape[0] + 1), 1)
......@@ -274,11 +277,13 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
ax.legend will create one label for each dot.
"""
# set height of legend and distance bw legend and upper ax
plot_h = self.plotting_axes.get_height(7, bw_plots_distance=0.003)
plot_h = self.plotting_axes.get_height(
21, bw_plots_distance=0.004, pixel_height=12)
ax = self.plotting_axes.canvas.figure.add_axes(
[self.plotting_l, self.plotting_bot, self.plotting_w, plot_h],
picker=True
)
ax.axis('off')
ax.patch.set_alpha(0)
c_labels = self.parent.sel_col_labels
clrs = self.parent.color_def # colordef
......
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