Skip to content
Snippets Groups Projects
Commit 2d285eee authored by antcsny's avatar antcsny
Browse files

Added axis plot

parent 19427d54
Branches
No related merge requests found
......@@ -226,9 +226,13 @@ class MainProgram (MainWindow):
def trace_selected_variables (self):
plt.close('all')
a = self.data.get_selected_axis()
if (len(a)==0):
sg.PopupOK("Select at least one axis to plot")
return
for i, var in enumerate(self.data._var_totrace):
if(self.data._do_trace_var[i]):
self.dataframe.plot(x="Sample_time_s",y=[f"{var}_A{i}" for i in range(1,7,1)], grid=True),plt.ylabel(f"Motor {var}")
self.dataframe.plot(x="Sample_time_s",y=[f"{var}_A{i}" for i in a], grid=True),plt.ylabel(f"Motor {var}")
plt.tight_layout()
plt.pause(0.1) # Alternative to plt.show() that is not blocking
......
......@@ -8,6 +8,7 @@ class UI_Data (sg.Frame):
_var_totrace = []
_do_trace_var = []
_do_trace_axis = [True, True, True, False, False]
def __init__ (self):
""" : Class constructor
......@@ -28,16 +29,19 @@ class UI_Data (sg.Frame):
self.trace_samples = sg.Button('Trace Sample collection history', key='-trace_sample-', disabled=True, expand_x=True)
self.trace_latency = sg.Button('Trace Sample latency distribution', key='-trace_latency-', disabled=True, expand_x=True)
self.do_axis = [ sg.Checkbox(f'A{i}', key=f'-do_axis{i}-', enable_events=True, default=True) for i in range(1,7)]
self.var_checkbox = []
self._layout = [
[ self._btn_start ],
[ sg.Frame("Quickview of the colelcted data in excel file :", border_width=0, expand_y=True, layout = [
[ sg.Frame("Quickview of the colelcted data in excel file :", expand_y=True, layout = [
[ sg.VPush() ],
[ self.import_data ],
[ self.trace_selvariables, self.trace_samples ],
[ self.trace_latency ],
[ sg.VPush() ]
[ sg.VPush() ],
[ sg.Frame("Axis to plot :", border_width=0.5, expand_x=True, layout = [self.do_axis ]) ]
]),
sg.Frame("Variables to plot :", layout=[ [sg.Col(layout=[], key='-col_var_to_plot-')] ])
],
......@@ -80,6 +84,15 @@ class UI_Data (sg.Frame):
"""
for i, _ in enumerate(self._var_totrace):
self._do_trace_var[i] = bool(self.var_checkbox[i].get())
def get_selected_axis (self):
i=1
res = []
for axis in self.do_axis:
if axis.get():
res.append(i)
i+=1
return res
def update_layout_on_columns(self, win: sg.Window, columns):
"""
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment