def load1_Score(self, path, filename): with open(filename[0], 'r') as stream: global micefeat global X array1 = pd.read_csv(stream) array = array1.values X = array[:, 2:56] plot = MeshLinePlot(color=[1, 0, 0, 1]) X_scaled = preprocessing.scale(X[:, 0]) plot.points = [(y, X_scaled[y]) for y in range(0, 500)] self.graph_test.add_plot(plot) global score_feat score_fe = array1.loc[:, 'time_stamps'] score_feat = pd.DataFrame(score_fe) score_feat.insert(1, 'EEG_spindelhan', array1.loc[:, 'EEG_spindelhan']) score_feat.insert(2, 'EMG_amplitude', array1.loc[:, 'EMG_amplitude']) score_feat.insert(3, 'EEG_delta', array1.loc[:, 'EEG_delta']) score_feat.insert(4, 'EMG_spectral_entropy', array1.loc[:, 'EMG_spectral_entropy']) score_feat.insert(5, 'EEG_theta1', array1.loc[:, 'EEG_theta1']) score_feat.insert(6, 'EEG_zerocross', array1.loc[:, 'EEG_zerocross']) self.dismiss_popup()
def init(self, octoprint): self.octoprint = octoprint # use kivy garden's graph widget graph = Graph( xlabel='', ylabel='°C', x_ticks_minor=5, x_ticks_major=25, y_ticks_minor=0, y_ticks_major=50, y_grid_label=True, x_grid_label=False, padding=5, y_grid=True, xmax=len(self.hotend_temps), ymax=230, _with_stencilbuffer=False, # or it does not work in ScreenManager label_options={'color': rgb('000000')}) self.hotend_plot = MeshLinePlot(color=[1, 0, 0, 1]) self.bed_plot = MeshLinePlot(color=[0, 0, 1, 1]) graph.add_plot(self.hotend_plot) graph.add_plot(self.bed_plot) self.ids.plot.add_widget(graph) self.graph = graph self.update_plot() self.status = "Ready."
def __init__(self, **kwargs): super(Plot, self).__init__(**kwargs) self.graph = Graph(xlabel="x", ylabel="y", x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1, draw_border=False) # graph.size = (1200, 400) # self.graph.pos = self.center self.plot = MeshLinePlot(color=[1, 1, 1, 1]) self.plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] self.plot2 = MeshLinePlot(color=[1, 0, 0, 1]) self.plot2.points = [(x, cos(x / 10.)) for x in range(0, 101)] self.add_widget(self.graph) self.graph.add_plot(self.plot) self.graph.add_plot(self.plot2)
def on_pre_enter(self): self.test_time = 0 self.temperature = 0 self.humidity = 0 self.location = 0 self.x_load = 0 self.y_load = 0 self.pot_angle = 0 self.imu_angle = 0 self.data_rate = 0 self.second_counter = 0 self.double_counter = 0 self.start_time = datetime.datetime.now() self.datasets = [] self.x_max1 = 5 self.y_max1 = 100 self.y_max2 = 5 self.x_major = int(self.x_max / 5) self.y_major1 = int(self.y_max1 / 5) self.y_major2 = int(self.y_max2 / 5) self.datasets = [] self.test_sensor = Sensor() self.plot1 = MeshLinePlot(color=[1, 1, 1, 1]) self.plot2 = MeshLinePlot(color=[1, 1, 1, 1]) self.event = Clock.schedule_interval(self.update_dataset, INTERVAL)
class LineGraph(Graph): xMax = NumericProperty(60.0) yMax = NumericProperty(1000.0) yMin = NumericProperty(0.0) xMin = NumericProperty(0.0) xLabel = Property("Time (s)") yLabel = Property("Altitude (m)") plot_1 = MeshLinePlot(color=[1, 0, 0, 1]) plot_2 = MeshLinePlot(color=[0, 1, 0, 1]) yVal_1 = NumericProperty(0.0) yVal_2 = NumericProperty(0.0) xVal = NumericProperty(0.0) def update(self, myflightdata): if not myflightdata.hasStarted: return m, s = divmod(myflightdata.TheTime.seconds, 60) milliseconds = myflightdata.TheTime.microseconds / 1000.0 self.xVal = m * 60.0 + s + milliseconds / 1000.0 self.yVal_1 = myflightdata.altitude_1 self.plot_1.points.append((self.xVal, self.yVal_1)) self.xMax = max(self.xMax, self.xVal + 5) self.yMax = max(self.yMax, self.yVal_1 + 30, self.yVal_2 + 30) self.add_plot(self.plot_1) if (myflightdata.parachute_1): self.yVal_2 = myflightdata.altitude_2 self.plot_2.points.append((self.xVal, self.yVal_2)) self.add_plot(self.plot_2)
def build(self): experiment = Experiment() plot = MeshLinePlot(color=[0,.75,.75,1]) plot.points = [] experiment.ids.graph.add_plot(plot) Clock.schedule_interval(partial(experiment.task, plot), 0.0) return experiment
def Create_Graph(self): for plot in self.graph.plots: self.graph.remove_plot(plot) n = int(self.p.text) if ((n % 2) == 0): list_b = [] i = -1 while i < 1: list_b.append(i) i = i + 0.1 data = [(x, (abs(1 - (x**n)))**(1 / n)) for x in list_b] data += [(x, ((abs(1 - (x**n)))**(1 / n) * -1)) for x in list_b] else: list_a = [] i = -4 while i < 1: list_a.append(i) i = i + 0.1 list_b = [] i = 1 while i < 6: list_b.append(i) i = i + 0.1 data = [(x, (abs(1 - (x**n)))**(1 / n)) for x in list_a] data += [(x, ((abs(1 - (x**n)))**(1 / n)) * -1) for x in list_b] plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = data self.graph.add_plot(plot)
def compute_contours(self): graph = self.graph if graph is None or not self.x2_variable: return for plot in self._contour_plots: self.graph.remove_plot(plot) plots = self._contour_plots = [] data = np.clip(self._yvals, self.y_start, self.y_end) xscale = (self.end - self.start) / self.num_points x2scale = (self.x2_end - self.x2_start) / self.num_points color = next(self.colors) for val in np.linspace(self.y_start, self.y_end, self.num_contours): contours = measure.find_contours(data, val) for contour in contours: contour[:, 0] *= xscale contour[:, 0] += self.start contour[:, 1] *= x2scale contour[:, 1] += self.x2_start plot = MeshLinePlot(color=color) plots.append(plot) graph.add_plot(plot) plot.points = contour
def graph_create(self): global graph1 graph1 = Graph( label_options={'color': rgb('001933'), 'bold': True}, background_color=rgb('f8f8f2'), tick_color=rgb('001933'), border_color=rgb('808080'), xlabel='X', ylabel='Y', y_grid_label=True, x_grid_label=True, padding=5, x_ticks_major=5, y_ticks_major=0.2, x_grid=True, y_grid=True, xmin=-0, xmax=30, ymin=-1, ymax=1) k = np.random.normal() global plot1 plot1 = MeshLinePlot(color=[0, 0, 0.75, 1]) y = (0.5 - 0.2)/30*np.linspace(0, max_year-1, max_year) + 0.2*np.ones(max_year) + np.random.normal(0, 0.05, max_year) plot1.points = [(x, y[x]) for x in range(0, 30)] graph1.add_plot(plot1) self.add_widget(graph1) return graph1
def load_graf(self,graf): #loads graph, updates global variable metrics with newest data0 global metrics, scaledmetrics graf.clear_widgets() try: RRData = ReadData() except: pass n=30 # n is currently used for RRMetrics and the number of points graphed. Split this try: pos = metrics[0][2][0] #Integer value of how many data points there have been except: pos = 0 graph = (Graph(xlabel = 'Data Point', ylabel = '% of Maximum', x_ticks_minor =1, x_ticks_major=2, y_ticks_minor=5,y_ticks_major=25,y_grid_label=True,x_grid_label=True, padding=5,x_grid=True,y_grid=True,xmin=max(0,pos-n+1),xmax=max(1,pos+1),ymin=0,ymax=100)) #Mod ymax/min based on bars xD for DataArray in scaledmetrics: metric = DataArray[0] #Metric Name as string colour = DataArray[1] #Metric colour plot = MeshLinePlot(color = colour) plot.points = tuple(DataArray[2:32]) #Replace 32 with some n variable plot.size = (1,1,100,100) graph.add_plot(plot) graf.add_widget(graph)
def graph_add(self): #self.remove_widget(graph1) global plot k = np.random.normal() plot = MeshLinePlot(color=[0, 0, 0.75, 1]) plot.points = [(x, sin(x / k)) for x in range(0, 101)] graph1.add_plot(plot)
def update_graph(self): SS = SecondScreen() x = SS.data[0] y = SS.data[1] plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x[i], y[i]) for i in range(len(x))] self.graph_test.add_plot(plot)
def graphpoints(self, *args): hotendactual_plot = SmoothLinePlot(color=[1, 0, 0, 1]) hotendtarget_plot = MeshLinePlot(color=[1, 0, 0, .75]) bedactual_plot = SmoothLinePlot(color=[0, 0, 1, 1]) bedtarget_plot = MeshLinePlot(color=[0, 0, 1, .75]) #Build list of plot points tuples from temp and time lists ##FIXME - Need to reduce the number of points on the graph. 360 is overkill hotendactual_points_list = [] hotendtarget_points_list = [] bedactual_points_list = [] bedtarget_points_list = [] for i in range(360): hotendactual_points_list.append( (graphtime_list[i]/1000.0*-1, hotendactual_list[i]) ) hotendtarget_points_list.append( (graphtime_list[i]/1000.0*-1, hotendtarget_list[i]) ) bedactual_points_list.append( (graphtime_list[i]/1000.0*-1, bedactual_list[i]) ) bedtarget_points_list.append( (graphtime_list[i]/1000.0*-1, bedtarget_list[i]) ) #Remove all old plots from the graph before drawing new ones for plot in self.my_graph.plots: self.my_graph.remove_plot(plot) #Draw the new graphs hotendactual_plot.points = hotendactual_points_list self.my_graph.add_plot(hotendactual_plot) hotendtarget_plot.points = hotendtarget_points_list self.my_graph.add_plot(hotendtarget_plot) bedactual_plot.points = bedactual_points_list self.my_graph.add_plot(bedactual_plot) bedtarget_plot.points = bedtarget_points_list self.my_graph.add_plot(bedtarget_plot)
def __init__(self, ): super(Logic, self).__init__() self.flag_start_stop = False self.theta = 0 self.plot = list() self.plot.append(MeshLinePlot(color=[1, 0, 0, 1])) self.plot.append(MeshLinePlot(color=[0, 1, 0, 1]))
def init(self): # use kivy garden's graph widget graph = Graph( xlabel='t', ylabel='HFR', x_ticks_minor=5, x_ticks_major=10, y_ticks_minor=1, y_ticks_major=5, y_grid_label=True, x_grid_label=False, padding=0, y_grid=False, x_grid=False, xmin=0, ymin=0, xmax=100, ymax=30, _with_stencilbuffer=False, # or it does not work in ScreenManager label_options={'color': rgb('808080')}) y = (float(i) for i in range(50)) x = (float(i) for i in range(50)) plot = MeshLinePlot(color=rgb('1100aa')) pts = list(zip(x, y)) plot.points = pts graph.add_plot(plot) self.ids.plot.add_widget(graph) self.plot = plot self.graph = graph
def __init__(self, **kwargs): super(SessionOverviewForm, self).__init__(**kwargs) access_token = '' self.transferData = TransferData(access_token) self.theta_plot = MeshLinePlot(color=[0, 0, 1, 1]) self.alpha2_plot = MeshLinePlot(color=[0, 1, 0, 1]) self.beta3_plot = MeshLinePlot(color=[1, 0, 0, 1]) self.active_profile = 'raw' self.selected_session = None
def __init__(self, ): super(Interface, self).__init__() self.contador = 0 self.plotsaida = MeshLinePlot(color=[1, 0, 0, 1]) self.plotentrada = MeshLinePlot(color=[1, 0, 0, 1]) self.plotsetpoint = MeshLinePlot(color=[0, 0, 1, 1]) self.plotsetpoint2 = MeshLinePlot(color=[0, 0, 1, 1]) self.plotaltura = MeshLinePlot(color=[0, 128, 0, 1])
def open(self): #inits plots self.plotT1 = MeshLinePlot(color=[1, 0.2, 0.2, 1]) #creates plot self.plotT2 = MeshLinePlot(color=[1, 0.7, 0.2, 1]) self.plotUef = MeshLinePlot(color=[0.6, 1, 0.2, 1]) self.plotT1.points = [] self.plotT2.points = [] self.plotUef.points = [] self.ids.graph.add_plot(self.plotT1) #adds plot to graph self.ids.graph.add_plot(self.plotT2) self.ids.graph.add_plot(self.plotUef)
def __init__(self, **kwargs): super(CustomGraph, self).__init__(**kwargs) self.xlabel = 'X' self.ylabel = 'Y' self.x_ticks_minor = 5 self.x_ticks_major = 25 self.y_ticks_major = 1 self.y_grid_label = True self.x_grid_label = True self.padding = 5 self.x_grid = True self.y_grid = True self.xmin = -0 self.xmax = 100 self.ymin = -5 self.ymax = 5 #graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, # x_ticks_major=25, y_ticks_major=1, # y_grid_label=True, x_grid_label=True, padding=5, # x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-5, ymax=5) plot1 = MeshLinePlot(color=[1, 0, 0, 1]) plot1.points = [(x, sin(x)) for x in range(0, 101)] plot2 = MeshLinePlot(color=[0, 1, 0, 1]) plot2.points = [(x, cos(x)) for x in range(0, 101)] plot3 = MeshLinePlot(color=[0, 0, 1, 1]) plot3.points = [(x, tan(x)) for x in range(0, 101)] self.add_plot(plot1) self.add_plot(plot2) self.add_plot(plot3)
def create_plots(self): # ---------------- for ACCELEROMETER sensor -------------------- self.accel_line_x = MeshLinePlot(color=[1, 0, 0, 1]) # X values are RED self.accel_line_y = MeshLinePlot(color=[0, 1, 0, 1]) # Y values are GREEN self.accel_line_z = MeshLinePlot(color=[0, 0, 1, 1]) # Z values are BLUE self.ids.accel_graph.add_plot(self.accel_line_x) self.ids.accel_graph.add_plot(self.accel_line_y) self.ids.accel_graph.add_plot(self.accel_line_z) # ---------------- for GYROSCOPE sensor ---------------------- self.gyro_line_x = MeshLinePlot(color=[1, 0, 0, 1]) # X values are RED self.gyro_line_y = MeshLinePlot(color=[0, 1, 0, 1]) # Y values are GREEN self.gyro_line_z = MeshLinePlot(color=[0, 0, 1, 1]) # Z values are BLUE self.ids.gyro_graph.add_plot(self.gyro_line_x) self.ids.gyro_graph.add_plot(self.gyro_line_y) self.ids.gyro_graph.add_plot(self.gyro_line_z) self.control_plot_error = MeshLinePlot(color=[1, 0, 0, 1]) self.control_plot_integral_error = MeshLinePlot(color=[0, 1, 0, 1]) self.control_plot_u = MeshLinePlot(color=[0, 0, 1, 1]) self.ids.control_graph.add_plot(self.control_plot_error) self.ids.control_graph.add_plot(self.control_plot_integral_error) self.ids.control_graph.add_plot(self.control_plot_u)
def build(self): print 'create graph' #self.canvas.add(Color(1., 1., 0)) graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot) return graph
def __init__(self, *args, **kwargs): super(ProjectGUI, self).__init__(*args, **kwargs) self.orientation = 'vertical' self.iter = 0 self.filt_iter = self.buffsize self.plots = {} self.plots['ecg'] = MeshLinePlot(color=[0, 1, 0, 1]) if self.plot_filter: self.plots['ecg_filtered'] = MeshLinePlot(color=[0, 1, 0, 1]) self.num_points = 5e3 # number of points per screen self.scale = self.graph1.xmax / float(self.num_points)
def build(self): self.title = "HP4156C Parameter Analyser" ## Main screen has a title and two accordions root = BoxLayout(orientation='vertical') ## Add a title header to the window graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1,y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot) root.add_widget(graph) return root
def update_dataset(self, obj): self.second_counter += 1 time_delta = datetime.datetime.now() - self.start_time total_time_passed = time_delta.seconds + (time_delta.microseconds * .000001) self.test_time = time_delta.seconds if self.second_counter >= SECOND_CAP / 2: self.double_counter += 1 self.second_counter = 0 self.graph1 = self.ids['graph_test1'] self.graph2 = self.ids['graph_test2'] self.graph1.remove_plot(self.plot1) self.graph2.remove_plot(self.plot2) self.graph1._clear_buffer() self.graph2._clear_buffer() self.plot1 = MeshLinePlot(color=[1, 1, 1, 1]) self.plot2 = MeshLinePlot(color=[1, 1, 1, 1]) last_index = len(self.datasets) - 1 self.x_max = math.ceil(self.datasets[last_index].timestamp / 5) * 5 self.y_max1 = max( self.y_max1, math.ceil(self.datasets[last_index].pot_angle / 100) * 100) self.y_max2 = max( self.y_max2, math.ceil(self.datasets[last_index].x_load / 5) * 5) #if(self.find_max_x_load() == 0): # self.y_max = 10000 #else: # self.y_max = math.ceil(self.find_max_x_load() / 10000) * 10000 self.x_major = int(self.x_max / 5) self.y_major1 = int(self.y_max1 / 5) self.y_major2 = int(self.y_max2 / 5) self.plot1.points = [(self.datasets[i].timestamp, self.datasets[i].pot_angle) for i in range(0, len(self.datasets), 5)] self.plot2.points = [(self.datasets[i].timestamp, self.datasets[i].x_load) for i in range(0, len(self.datasets), 5)] self.graph1.add_plot(self.plot1) self.graph2.add_plot(self.plot2) sensor_values = self.test_sensor.get_sensor_data() self.x_load = sensor_values["X Load"] self.y_load = sensor_values["Y Load"] self.pot_angle = sensor_values["Pot Angle"] self.imu_angle = sensor_values["IMU Angle"] new_dataset = Dataset(total_time_passed, self.x_load, self.y_load, self.pot_angle, self.imu_angle, self.data_rate) self.datasets.append(new_dataset)
def __init__(self, num_data_points=100, **kwargs): super(GraphScreen, self).__init__() self.tempplot = MeshLinePlot(color=[1, 0, 0, 1]) self.pHplot = MeshLinePlot(color=[1, 0, 0, 1]) self.DOplot = MeshLinePlot(color=[1, 0, 0, 1]) self._num_data_points = num_data_points self.xmin = 0 self.xmax = num_data_points self.range = '5 Minutes' self.fermenter = 'Fermenter 1' self.filename = None
def on_enter(self): self.graph = self.ids['graph_test'] self.plot = MeshLinePlot(color=[1, 1, 1, 1]) ts = TestSingleton() self.datasets = ts.get_datasets() last_index = len(self.datasets) - 1 if math.ceil( max(self.datasets[i].pot_angle for i in range(0, len(self.datasets))) / 100) > 0: self.x_max = math.ceil( max(self.datasets[i].pot_angle for i in range(0, len(self.datasets))) / 100) * 100 else: self.x_max = 100 if math.ceil( max(self.datasets[i].x_load for i in range(0, len(self.datasets))) / 5) > 0: self.y_max = math.ceil( max(self.datasets[i].x_load for i in range(0, len(self.datasets))) / 5) * 5 else: self.y_max = 5 self.x_major = int(self.x_max / 5) self.y_major = int(self.y_max / 5) self.plot.points = [(self.datasets[i].pot_angle, self.datasets[i].x_load) for i in range(0, len(self.datasets))] self.graph.add_plot(self.plot)
def __init__(self, **kw): super(PreTestScreen, self).__init__(**kw) self.plot = MeshLinePlot(color=[1, 0, 0, 1]) global pr_fev1_avg, pr_fvc_avg, pr_fev1_fvc_avg, pr_fet_avg, pr_pvf_avg, pr_fef25_avg, pr_fef_50_75_avg # calculates average of all the pre tests. pr_fev1_avg = ((int(self.ids['p_pr_fev1_t1'].text) + int(self.ids['p_pr_fev1_t2'].text) + int(self.ids['p_pr_fev1_t3'].text) + int(self.ids['p_pr_fev1_t4'].text) + int(self.ids['p_pr_fev1_t5'].text) + int(self.ids['p_pr_fev1_t6'].text)) / 6) pr_fvc_avg = ((int(self.ids.p_pr_fvc_t1.text) + int(self.ids.p_pr_fvc_t2.text) + int(self.ids.p_pr_fvc_t3.text) + int(self.ids.p_pr_fvc_t4.text) + int(self.ids.p_pr_fvc_t5.text) + int(self.ids.p_pr_fvc_t6.text)) / 6) pr_fev1_fvc_avg = ((int(self.ids.p_pr_fev1_fvc_t1.text) + int(self.ids.p_pr_fev1_fvc_t2.text) + int(self.ids.p_pr_fev1_fvc_t3.text) + int(self.ids.p_pr_fev1_fvc_t4.text) + int(self.ids.p_pr_fev1_fvc_t5.text) + int(self.ids.p_pr_fev1_fvc_t6.text)) / 6) pr_fet_avg = ((int(self.ids.p_pr_fet_t1.text) + int(self.ids.p_pr_fet_t2.text) + int(self.ids.p_pr_fet_t3.text) + int(self.ids.p_pr_fet_t4.text) + int(self.ids.p_pr_fet_t5.text) + int(self.ids.p_pr_fet_t6.text)) / 6) pr_pvf_avg = ((int(self.ids.p_pr_pvf_t1.text) + int(self.ids.p_pr_pvf_t2.text) + int(self.ids.p_pr_pvf_t3.text) + int(self.ids.p_pr_pvf_t4.text) + int(self.ids.p_pr_pvf_t5.text) + int(self.ids.p_pr_pvf_t6.text)) / 6) pr_fef25_avg = ((int(self.ids.p_pr_fef25_t1.text) + int(self.ids.p_pr_fef25_t2.text) + int(self.ids.p_pr_fef25_t3.text) + int(self.ids.p_pr_fef25_t4.text) + int(self.ids.p_pr_fef25_t5.text) + int(self.ids.p_pr_fef25_t6.text)) / 6) pr_fef_50_75_avg = ((int(self.ids.p_pr_fef50_75_t1.text) + int(self.ids.p_pr_fef50_75_t2.text) + int(self.ids.p_pr_fef50_75_t3.text) + int(self.ids.p_pr_fef50_75_t4.text) + int(self.ids.p_pr_fef50_75_t5.text) + int(self.ids.p_pr_fef50_75_t6.text)) / 6)
def __init__(self): super(AccelerometerDemo, self).__init__() self.sensorEnabled = False self.graph = self.ids.graph_plot # For all X, Y and Z axes self.plot = [] self.plot.append(MeshLinePlot(color=[1, 0, 0, 1])) # X - Red self.plot.append(MeshLinePlot(color=[0, 1, 0, 1])) # Y - Green self.plot.append(MeshLinePlot(color=[0, 0, 1, 1])) # Z - Blue self.reset_plots() for plot in self.plot: self.graph.add_plot(plot)
def __init__(self, **kwargs): self.isrecording = False # to control start and stop super(Logic, self).__init__( **kwargs ) # The function returns a temporary object that allows reference to a # parent class self.plot = MeshLinePlot(color=[1, 0, 0, 1]) # plotting and its color
def build(self): self.availablePorts = listSerialPorts() if len(self.availablePorts) == 0: self.availablePorts.append("----") tabbedPannel = TabbedPanel(do_default_tab=False) # Connection Tab self.connectionTab = TabbedPanelItem(text="Connection") self.layout1 = BoxLayout(orientation='vertical', spacing=10, padding=(200, 200)) self.connectionTab.add_widget(self.layout1) self.lblSerialSettings = Label(text="Connection settings") self.layout1.add_widget(self.lblSerialSettings) self.dlBaudrate = Spinner(values = ["57600", "115200", "230400", "460800", "921600"], text = "115200") self.layout1.add_widget(self.dlBaudrate) self.dlPort = Spinner(values = self.availablePorts, text = self.availablePorts[0]) self.layout1.add_widget(self.dlPort) self.btnConnect = Switch() self.btnConnect.bind(active = self.connect) self.layout1.add_widget(self.btnConnect) # Graph tab self.graphTab = TabbedPanelItem(text = "Graph") # self.layout2 = BoxLayout(orientation='vertical', spacing=10, padding=(200, 200)) # self.graphTab.add_widget(self.layout2) graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 1, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot) self.graphTab.add_widget(graph) tabbedPannel.add_widget(self.connectionTab) tabbedPannel.add_widget(self.graphTab) return tabbedPannel
def __init__(self): super(ViViChart, self).__init__() graph_theme = {'background_color': 'f8f8f2'} self.graph = self.ids.graph self.plot = MeshLinePlot(color=[1, 0, 0, 1]) self.plot.points = [] self.graph.add_plot(self.plot) self.start = time.time()
def build(self): print 'create graph' graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=10, ymin=-12, ymax=12) plot = MeshLinePlot(color=[1, 0, 0, 1]) with open("adclog.txt") as fh: coords = [] for line in fh: line = line.strip('()\n') # Get rid of the newline and parentheses line = line.split(', ') # Split into two parts c = tuple(float(x) for x in line) # Make the tuple coords.append(c) plot.points = coords graph.add_plot(plot) return graph
def update_graph(self, instance): ids = self.ids if str(instance.id) == 'up': # determine upper/lower bounds upper_bound = self.dm.str_to_date(instance.text) lower_bound = self.dm.str_to_date(self.beginbtn.text) elif str(instance.id) == 'lo': upper_bound = self.dm.str_to_date(self.endbtn.text) lower_bound = self.dm.str_to_date(instance.text) else: upper_bound = self.dm.str_to_date(self.endbtn.text) lower_bound = self.dm.str_to_date(self.beginbtn.text) if lower_bound.day >= 10: ids.graphid.xmin = int( str(lower_bound.month) + str(lower_bound.day)) else: ids.graphid.xmin = int( str(lower_bound.month) + '0' + str(lower_bound.day)) if upper_bound.day >= 10: ids.graphid.xmax = int( str(upper_bound.month) + str(upper_bound.day)) else: ids.graphid.xmax = int( str(upper_bound.month) + '0' + str(upper_bound.day)) print ids.graphid.xmax print ids.graphid.xmin plot = MeshLinePlot(color=[.1, .7, 1, 1]) #plot.points = [(x, 30*sin(x / 10.)+100+(x)) for x in range(0, 101)] rows = self.dm.get_whole_table("data") result = [] carbavg = 0 bgavg = 0 dev = 0 for row in rows: date = self.dm.str_to_date(row["dateColumn"]) if date >= lower_bound and date <= upper_bound: carbavg += row["Carbs"] bgavg += row["Bg"] dev = 10 result.append(row) rows = result if len(rows) > 0: ids.average_lbl.text = str(bgavg / len(rows)) ids.deviation_lbl.text = "±" + str(dev / len(rows)) ids.carbs_lbl.text = str(carbavg / len(rows)) #plot.points =[(int(str(self.dm.str_to_date(row["Date"]).month)+str(self.dm.str_to_date(row["Date"]).day)), row["Bg"]) for row in rows] for row in rows: date = self.dm.str_to_date(row["dateColumn"]) if date.day >= 10: dateint = int(str(date.month) + str(date.day)) else: dateint = int(str(date.month) + '0' + str(date.day)) point = (dateint, row["Bg"]) plot.points.append(point) ids.graphid.add_plot(plot)
def __init__(self): self.graph_theme = { 'label_options': { 'color': rgb('444444'), # color of tick labels and titles 'bold': True }, 'background_color': rgb('b8b7bb'), # back ground color of canvas 'tick_color': rgb('808080'), # ticks and grid 'border_color': rgb('808080') } # border drawn around each graph self.graph_canvas = BoxLayout(orientation='vertical', padding=5) self.graph_rain = Graph(ylabel="rainfall(mm/s)", y_grid_label=True, x_grid_label=True, xmin=0, xmax=10, ymin=0, ymax=5000, x_ticks_major=5, y_ticks_major=2500, x_ticks_minor=1, y_ticks_minor=100, x_grid=True, y_grid=True, padding=5, **self.graph_theme) self.graph_temp = Graph(ylabel="temperature (C)", y_grid_label=True, x_grid_label=True, xmin=0, xmax=10, ymin=0, ymax=50, x_ticks_major=5, y_ticks_major=25, x_ticks_minor=1, y_ticks_minor=5, x_grid=True, y_grid=True, padding=5, **self.graph_theme) self.plot_rain = MeshLinePlot(color=[0, 0, 1, 1]) self.plot_temp = MeshLinePlot(color=[1, 0, 0, 1])
def zaladujModel(self, sciezka): import random self.data.loadFile(sciezka, app, wantSorted=True, index=0) for property in self.data.temp: r = lambda: random.randint(0, 255) / 255.0 plot = MeshLinePlot(color=[r(), r(), r(), 1]) points = [] i = 0 for object in self.data.data: try: value = float(object[property]) points.append((i, value)) except (ValueError, KeyError): pass i += 1 plot.points = points app.graphScreen.getGraph().add_plot(plot)
def __init__(self, **kwargs): super(BElGenLiveGraph, self).__init__(**kwargs) graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=10, ymin=-12, ymax=12) plot = MeshLinePlot(color=[1, 0, 0, 1]) with open("adclog.txt") as fh: coords = [] for line in fh: line = line.strip('()\n') # Get rid of the newline and parentheses line = line.split(', ') # Split into two parts c = tuple(float(x) for x in line) # Make the tuple coords.append(c) plot.points = coords graph.add_plot(plot) self.add_widget(graph)
def zaladujModel(self,sciezka): import random self.data.loadFile(sciezka, app, wantSorted=True, index=0) for property in self.data.temp: r = lambda: random.randint(0,255)/255.0 plot = MeshLinePlot(color=[r(), r(), r(), 1]) points = [] i = 0 for object in self.data.data: try: value = float(object[property]) points.append((i, value)) except (ValueError, KeyError): pass i+=1 plot.points = points app.graphScreen.getGraph().add_plot(plot)
def mostrar_histograma(self): """ Mostra o histograma da imagem. """ histograma = self.imagem_core.get_histograma() graph = Graph(xlabel='Tom de Cinza', ylabel='Quantidade de tons', padding=5, xmin=0, xmax=max(histograma.keys()), ymin=0, ymax=max(histograma.values())) plot = MeshLinePlot() plot.points = histograma.items() graph.add_plot(plot) self.widgets_dinamicos.append(graph) self.add_widget(graph)
def load_Feat(self, path, filename): with open(os.path.join(path, filename[0]), 'r') as stream: global data_frame print(filename[0]) print(stream) eeg1, eeg2, emg, time_stamps = readEDFfile(filename[0], EMGC, EEGC, epoch) print("EDF read") print(eeg1) print(emg) data_frame = CreateFeaturesDataFrame(eeg1, emg, epoch, fs) data_frame['time_stamps'] = time_stamps plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, eeg1[x]) for x in range(0, 1500)] self.graph_test.add_plot(plot) self.dismiss_popup()
def plotGraph(self, amplit): numAmp = float(amplit) self.my_output.text = "graph" for plot in self.my_graph.plots: self.my_graph.remove_plot(plot) plot = MeshLinePlot(mode="line_strip", color=[1, 0, 0, 1]) plot.points = [(x, 10 * np.sin(0.5 * x / numAmp)) for x in xrange(-0, 100)] self.my_graph.add_plot(plot) self.my_graph.x_ticks_major = 25 self.my_graph.y_ticks_major = 25 self.my_graph.xmin = -0 self.my_graph.xmax = 100 self.my_graph.ymin = -25 self.my_graph.ymax = 25 self.my_graph.xlabel = "X axis" self.my_graph.ylabel = "Y axis"
def update_plot_instructions(self): '''Updates the graphics instructions when the plot is shown/hidden. Returns True when the plot was shown/hidden and False otherwise. ''' changed = False vals = self.color_values rate = self.frame_rate for i, chan in enumerate('rgb'): active = getattr(self, '{}_btn'.format(chan)).state == 'down' plot_attr = '{}_plot'.format(chan) if active and not getattr(self, plot_attr): if not self.r_plot and not self.g_plot and not self.b_plot: with self.graph_canvas: c = Color(*get_color_from_hex('ebebeb')) r = Line() self.background = [r, c] color = [0, 0, 0, 1] color[i] = 1 plot = MeshLinePlot(color=color) plot.params['ymin'] = 0 plot.params['ymax'] = 1 add = self.graph_canvas.add for instr in plot.get_drawings(): add(instr) plot.ask_draw() setattr(self, plot_attr, plot) changed = True elif not active and getattr(self, plot_attr): changed = True plot = getattr(self, plot_attr) remove = self.graph_canvas.remove for instr in plot.get_drawings(): remove(instr) setattr(self, plot_attr, None) if not self.r_plot and not self.g_plot and not self.b_plot: for instr in self.background: remove(instr) self.background = [] return changed
def addData(self): p = MeshLinePlot(color=[1,0,0,1]) p.points = [(x, 0.5) for x in range(-10,10)] self.ids['my_graph'].add_plot(p)
def on_open(self): plot = MeshLinePlot(color=[0,1,1,1]) plot.points = zip(np.arange(self.spectrum.size), self.spectrum) self.ids.graph.add_plot(plot)