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, 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."
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 __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 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)
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, **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 __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 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, ): 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 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 __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 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 graphpoints(self, *args): global g_hotend_actual global g_hotend_target global g_bed_actual global g_bed_target 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]) # Update temperature graph arrays with new data hotendactual_list.popleft() hotendactual_list.append(g_hotend_actual) hotendtarget_list.popleft() hotendtarget_list.append(g_hotend_target) bedactual_list.popleft() bedactual_list.append(g_bed_actual) bedtarget_list.popleft() bedtarget_list.append(g_bed_target) # Build list of plot points tuples from temp and time lists hotendactual_points_list = [] hotendtarget_points_list = [] bedactual_points_list = [] bedtarget_points_list = [] for i in range(temperature_list_size): hotendactual_points_list.append( (graphtime_list[i] / 1000.0 * -1, int(hotendactual_list[i]))) hotendtarget_points_list.append( (graphtime_list[i] / 1000.0 * -1, int(hotendtarget_list[i]))) bedactual_points_list.append( (graphtime_list[i] / 1000.0 * -1, int(bedactual_list[i]))) bedtarget_points_list.append( (graphtime_list[i] / 1000.0 * -1, int(bedtarget_list[i]))) # Remove all old plots from the graph before drawing new ones while (len(self.my_graph.plots) != 0): # TODO - add a counter so we can abort after a certain number of tries. self.my_graph.remove_plot(self.my_graph.plots[0]) # 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 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 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, **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 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): 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): # 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 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 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 __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 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 __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 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 pintar(self): print("update_graph") self.plot = MeshLinePlot(color=[1, 0, 0, 1]) self.plot.points = [(x, sin(x / 10.)) for x in range(0, 20)] self.x = 20 print(self.plot) print(self.plot.points) self.ids["graph_test"].add_plot(self.plot) print(self.graph_test) print("CLICK!!!")
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