예제 #1
0
    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(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 = SmoothLinePlot(color=[0.49, 0.98, 1, 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)
예제 #3
0
파일: stats.py 프로젝트: chae9214/inversion
    def get_daily_cost(self):
        if self.flag == 1:
            return

        self.flag = 1
        day_list = days_to_ints(get_all_days())
        my_day_list = {}

        for (m, d) in day_list:
            if m in my_day_list:
                my_day_list[m].append(d)
            else:
                my_day_list[m] = []
                my_day_list[m].append(d)

        new_day_list = []

        for eachMonth in my_day_list:
            for eachDay in my_day_list[eachMonth]:
                new_day_list.append(eachDay + (eachMonth - 1) * 30)

        day_cost = get_daily_cost()

        points_list = self.make_pairs(new_day_list, day_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list

        self.graph8.add_plot(plot)

        self.ids['graph1'].remove_widget(self.graph2)
        self.ids['graph1'].remove_widget(self.graph1)
        self.ids['graph1'].add_widget(self.graph8)
예제 #4
0
    def __init__(self, n, S, C, t, I):
        """
        Paramètres
        ----------
        n : int
            Nombre d'électrons échangés au cours de la réaction.
        S : float
            Surface d'échange.
        C : float
            Concentration de l'espèce.
        t : list
            Tableau de valeurs des temps expérimentaux.
        I : list
            Tableau de valeurs des intensités mesurées expérimentalement.
        """
        super(GraphLinearRegression, self).__init__(t, I)
        self.n = n
        self.S = S
        self.C = C

        graph_theme = {
            'label_options': {
                'color': [0, 0, 0, 1],  # color of tick labels and titles
                'bold': False
            },
            'background_color': [1, 1, 1, 1],  # back ground color of canvas
            'tick_color': [0, 0, 0, 1],  # ticks and grid
            'border_color': [0, 0, 0, 1]
        }  # border drawn around each graph

        self.graph = Graph(title='Courbes de Regression lineaire',
                           xlabel='log Temps (s)',
                           ylabel='log Intensité (A)',
                           x_ticks_minor=5,
                           x_ticks_major=5,
                           y_ticks_major=0.2,
                           y_ticks_minor=4,
                           y_grid_label=True,
                           x_grid_label=True,
                           padding=5,
                           x_grid=False,
                           y_grid=False,
                           precision="%#.4g",
                           **graph_theme)

        self.logexpplot = SmoothLinePlot(color=[1, 0, 0, 1])
        self.logexpplot.label = "Expérimentale"

        self.linlogexpplot = SmoothLinePlot(color=[1, 0, 1, 1])

        self.graph.legend = True

        self.graph.add_plot(self.logexpplot)
        self.graph.add_plot(self.linlogexpplot)

        self._trigger = Clock.create_trigger(self.update_ticks)
        self.graph._plot_area.bind(pos=self._trigger)
예제 #5
0
파일: main.py 프로젝트: homdx/mohr
    def desenha_eixos(self):
        # Desenho dos graficos
        self.eixo_x = SmoothLinePlot(color=[0, 1, 1, 1])
        self.eixo_x.points = [(self.xmin, 0), (self.xmax, 0)]
        self.eixo_y = SmoothLinePlot(color=[0, 1, 1, 1])
        self.eixo_y.points = [(0, self.ymin), (0, self.ymax)]

        # Exibindo os graficos
        self.propriedade_grafico.add_plot(self.eixo_x)
        self.propriedade_grafico.add_plot(self.eixo_y)
예제 #6
0
    def build(self, name, color, before, after):
        self.name.text = name

        self.bplot = SmoothLinePlot(color=COLOR_GRAY)
        self.bplot.points = build_points(*before)
        self.graph.add_plot(self.bplot)

        self.aplot = SmoothLinePlot(color=color)
        self.aplot.points = build_points(*after)
        self.graph.add_plot(self.aplot)
예제 #7
0
파일: main_kivy.py 프로젝트: matrix303/USRP
 def __init__(self, **kwargs):
     super(HomeScreen, self).__init__(**kwargs)
     self.temp_plot = SmoothLinePlot(color=[1, 0, 0, 1])
     self.temp_set_plot = MeshLinePlot(color=[0.7, 0, 0, 1])
     self.od_plot = SmoothLinePlot(color=[1, 0.5, 0, 1])
     self.od_set_plot = MeshLinePlot(color=[0.7, 0.3, 0, 1])
     self.led_plot = MeshLinePlot(color=[1, 1, 0, 1])
     self.peltier_plot = MeshLinePlot(color=[1, 0, 0.5, 1])
     self.stir_plot = MeshLinePlot(color=[0, 1, 0, 1])
     self.mot_in_plot = MeshLinePlot(color=[0, 0, 1, 1])
     self.mot_out_plot = MeshLinePlot(color=[0, 1, 1, 1])
예제 #8
0
    def __init__(self, t=[], I=[]):
        """
        Paramètres
        ----------
        t : list
            Tableau de valeurs de temps.
        I : list
            Tableau de valeurs d'intensité.
        """
        super(CottrellGraph, self).__init__(t, I)

        graph_theme = {
            'label_options': {
                'color': [0, 0, 0, 1],  # color of tick labels and titles
                'bold': False
            },
            'background_color': [1, 1, 1, 1],  # back ground color of canvas
            'tick_color': [0, 0, 0, 1],  # ticks and grid
            'border_color': [0, 0, 0, 1]
        }  # border drawn around each graph

        self.graph = Graph(title='Courbes de Cottrell',
                           xlabel='Temps (s)',
                           ylabel='Intensité (A)',
                           x_ticks_minor=5,
                           x_ticks_major=5,
                           y_ticks_major=0.2,
                           y_ticks_minor=4,
                           y_grid_label=self.ticks_labels,
                           x_grid_label=self.ticks_labels,
                           padding=5,
                           x_grid=False,
                           y_grid=False,
                           xmin=float(self.tleft),
                           xmax=float(self.tright),
                           ymin=float(self.Ibottom),
                           ymax=float(self.Itop),
                           legend=self.legend,
                           precision="%#.4g",
                           **graph_theme)

        self.thplot = SmoothLinePlot(color=[0, 0, 1, 1])
        self.thplot.label = "Théorique"

        self.expplot = SmoothLinePlot(color=[1, 0, 0, 1])
        self.expplot.label = "Expérimentale"

        self.bind(legend=self.graph.setter('legend'))
        self.bind(ticks_labels=self.graph.setter('y_grid_label'))
        self.bind(ticks_labels=self.graph.setter('x_grid_label'))

        self._trigger = Clock.create_trigger(self.update_ticks)
        self.graph.bind(size=self._trigger)
        self.graph._plot_area.bind(pos=self._trigger)
예제 #9
0
 def __init__(self,**kwargs):
     super(ReactorScreen4, self).__init__(**kwargs)
     self.name = "reactor4"
     Clock.schedule_once(self._finish_init)
     Clock.schedule_interval(self.get_value, 1)
     self.plot_temp = SmoothLinePlot(color = get_color_from_hex('#23C48E'))
     self.plot_humidity = SmoothLinePlot(color = get_color_from_hex('#04C0F8'))
     self.rangedict = ['No not', '12/10/1', '24']
     self.y_axis_min = 0
     self.y_axis_max = 100
     self.time_duration = 2
예제 #10
0
 def __init__(self,**kwargs):
     super(ReactorScreen1, self).__init__(**kwargs)
     self.name = "reactor1"
     global rangedict
     Clock.schedule_once(self._finish_init)
     Clock.schedule_interval(self.get_value, 0.7)
     self.plot_temp = SmoothLinePlot(color = get_color_from_hex('00FCC6'))
     self.plot_humidity = SmoothLinePlot(color = get_color_from_hex('00BFFF'))
     self.rangedict = ['No not', '12/10/1', '24']
     self.y_axis_min = 0
     self.y_axis_max = 100
     self.time_duration = 2
예제 #11
0
파일: GUI.py 프로젝트: abre049/IncuBeerTor
    def update_plot(self, event=False):
        profile_scrollview = self.get_widget(self, 'profile_scrollview')
        profile_gridlayout = self.get_widget(profile_scrollview, 'profile_gridlayout')
        box = self.get_widget(profile_gridlayout, 'box')
        profile_graph = self.get_widget(box, 'profile_graph')

        profile_plot = SmoothLinePlot(color=[1,0,0,1])
        profile_plot.points = [(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()] #(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()
        # print profile_plot.points
        for plot in profile_graph.plots:
            profile_graph.remove_plot(plot)
        profile_graph.add_plot(profile_plot)
예제 #12
0
파일: GUI.py 프로젝트: abre049/IncuBeerTor
    def update_plot(self, event=False):
        monitor_scrollview = self.get_widget(self, 'monitor_scrollview')
        monitor_gridlayout = self.get_widget(monitor_scrollview, 'monitor_gridlayout')
        box = self.get_widget(monitor_gridlayout, 'box')
        monitor_graph = self.get_widget(box, 'monitor_graph')

        profile_plot = SmoothLinePlot(color=[1,0,0,1])
        profile_plot.points = [(float(x[1]['time']), float(x[1]['temperature'])) for x in self.unfilled_profile.iterrows()] #(float(x[1][0]), float(x[1][1])) for x in self.current_profile_df.iterrows()
        # brew_plot = SmoothLinePlot(color=[0,1,0,1])
        # brew_plot.points = [(float(x[1][0]), float(x[1][1])) for x in self.brew_df.iterrows()]
        for plot in monitor_graph.plots:
            monitor_graph.remove_plot(plot)
        monitor_graph.add_plot(profile_plot)
예제 #13
0
파일: main.py 프로젝트: homdx/mohr
 def desenha_circulo(self, raio, centro_x):
     self.plot_circulo = SmoothLinePlot(color=[1, 0, 0, 1])
     self.plot_circulo.points = [
         (centro_x + raio * math.cos(theta * .01),
          raio * math.sin(theta * .01)) for theta in range(0, 1300)
     ]  # 130 => 40*pi (para dar 2 voltas completas)
     self.propriedade_grafico.add_plot(self.plot_circulo)
    def use_signals_config(self, signal_sources_config):
        self.graph_labels = []

        self.history = SignalHistory()
        if 'history_max' in signal_sources_config:
            self.history.max_seconds = signal_sources_config['history_max']
        if 'history_delta' in signal_sources_config:
            self.history.delta_seconds = signal_sources_config['history_delta']

        self.plots = []
        self.graph_visible = []

        for group in signal_sources_config['groups']:
            group_label = group['label']
            for source in group['sources']:
                self.graph_labels.append(group_label + ' ' + source.label)
                self.history.add_source(source)
                self.graph_visible.append(source.with_graph)
                plot = SmoothLinePlot(color=source.color)
                self.plots.append(plot)

        for source_plot in sorted(zip(self.history.sources, self.plots),
                                  key=lambda sp: sp[0].z_order):
            self.ids.graphs_canvas.add_plot(source_plot[1])

        self.history.write_to_csv('csv/signals')
        self.history.load_from_csv_files()
        self.history.start()

        self.x_range = self.history.max_seconds
        self.x_max = None

        Clock.schedule_once(self.update_graphs, 0.)
예제 #15
0
    def __init__(self, x=[], cox=[]):
        """
        Paramètres
        ----------
        x : list
            Tableau des distances à l'électrode.
        cox : list
            Tableau de la concentration.
        """
        self.x = x
        self.cox = cox

        theme_cls = App.get_running_app().theme_cls
        graph_theme={}
        if App.get_running_app().theme == 'default':
            graph_theme = {
                    'label_options': {
                        'color': [0, 0, 0, 1],  # color of tick labels and titles
                        'bold': False,
                        'markup': True},
                    'background_color': [1, 1, 1, 1],  # back ground color of canvas
                    'tick_color': [0, 0, 0, 1],  # ticks and grid
                    'border_color': [0, 0, 0, 1]}  # border drawn around each graph
        elif App.get_running_app().theme ==  'material-design':
            graph_theme = {
                    'label_options': {
                        'color': get_color_from_hex(colors[theme_cls.primary_palette][theme_cls.primary_hue]),#[0, 0, 0, 1],  # color of tick labels and titles
                        'bold': False,
                        'markup': True},
                    'background_color': get_color_from_hex(colors[theme_cls.theme_style]["Background"]),#[1, 1, 1, 1],  # back ground color of canvas
                    'tick_color': get_color_from_hex(colors[theme_cls.accent_palette][theme_cls.accent_hue]),#[0, 0, 0, 1],  # ticks and grid
                    'border_color': get_color_from_hex(colors[theme_cls.accent_palette][theme_cls.accent_hue])}#[0, 0, 0, 1]}  # border drawn around each graph
                
        self.graph = Graph(title = 'Courbe C[sub]ox[/sub]',
                           xlabel='x',
                           ylabel='C[sub]ox[/sub] / C[sup]*[/sup] [sub]ox[/sub]',
                           x_ticks_minor=5,
                           x_ticks_major=5,
                           y_ticks_major=1,
                           y_ticks_minor=4,
                           y_grid_label=True,
                           x_grid_label=True,
                           padding=5,
                           x_grid=False,
                           y_grid=False, 
                           xmin=float(0),
                           xmax=float(0.05), 
                           ymin=float(0),
                           ymax=float(1),
                           precision="%#.4g",
                           **graph_theme)
        
        self.coxplot = SmoothLinePlot(color=[0, 0, 1, 1])
        self.coxplot.label = "Concentration"

        self.graph.add_plot(self.coxplot)
        
        self._trigger = Clock.create_trigger(self.update_ticks)
        self.graph._plot_area.bind(pos=self._trigger)
예제 #16
0
파일: main.py 프로젝트: homdx/mohr
 def desenha_angulo(self, centro_x, raio):
     self.arco_angulo = SmoothLinePlot(color=[1, 1, 0, 1])
     self.arco_angulo.points = [
         (centro_x + 0.1 * raio * math.cos(theta * .1),
          0.1 * raio * math.sin(theta * .1))
         for theta in range(0, int(20 * self.angulo + 2))
     ]
     self.propriedade_grafico.add_plot(self.arco_angulo)
예제 #17
0
파일: stats.py 프로젝트: chae9214/inversion
    def get_monthly_cost(self):
        if self.flag == 3:
            return

        self.flag = 3

        month_list = get_all_months()
        month_cost = get_monthly_cost()
        points_list = self.make_pairs(month_list, month_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list
        self.graph1.add_plot(plot)
        self.ids['graph1'].remove_widget(self.graph8)
        self.ids['graph1'].remove_widget(self.graph2)
        self.ids['graph1'].add_widget(self.graph1)
예제 #18
0
파일: stats.py 프로젝트: chae9214/inversion
    def get_weekly_cost(self):
        if self.flag == 2:
            return

        self.flag = 2

        week_list = get_all_weeks()
        week_cost = get_weekly_cost()
        points_list = self.make_pairs(week_list, week_cost)
        print(points_list)

        plot = SmoothLinePlot(color=[162 / 255.0, 121 / 255.0, 119 / 255.0, 1])
        plot.points = points_list
        self.graph2.add_plot(plot)
        self.ids['graph1'].remove_widget(self.graph8)
        self.ids['graph1'].remove_widget(self.graph1)
        self.ids['graph1'].add_widget(self.graph2)
예제 #19
0
    def create_kivy_plot(self,
                         series=np.array(range(12)),
                         label_y='Average Response Time'):
        if self.graph_figure:
            self.destroy()

        series_len = len(series)
        if series_len == 0:
            return False
        max_y = max(series)
        min_y = min(series)
        #arg_max_y = series.index(max_y) # use this to label max and min...
        #arg_min_y = series.index(min_y) # with their resp time stamp
        ticks_y = round(max_y / 10., 2)

        graph_theme = {
            'label_options': {
                'color': rgb('444444'),  # color of tick labels and titles
                'bold': True
            },
            'background_color': rgb('000000'),  # back ground color of canvas
            'tick_color': rgb('444444'),  # ticks and grid
            'border_color': rgb('444444')
        }  # border drawn around each graph

        self.graph_figure = Graph(xlabel='Last {} games'.format(series_len),
                                  ylabel=label_y,
                                  x_ticks_minor=5,
                                  x_ticks_major=5,
                                  y_ticks_major=ticks_y,
                                  y_grid_label=True,
                                  x_grid_label=True,
                                  padding=10,
                                  x_grid=False,
                                  y_grid=True,
                                  xmin=0,
                                  xmax=series_len,
                                  ymin=0,
                                  ymax=int(1.2 * max_y + 1),
                                  _with_stencilbuffer=False,
                                  **graph_theme)
        plot = SmoothLinePlot(color=next(self.colors))  #mode='line_strip',
        plot.points = [(x, series[x - 1]) for x in range(1, len(series) + 1)]
        self.graph_figure.add_plot(plot)

        self.add_widget(self.graph_figure)
예제 #20
0
파일: stats.py 프로젝트: chae9214/inversion
    def get_weekly_mistakes(self):
        if self.flag == 5:
            return

        self.flag = 5

        week_list = get_all_weeks()

        week_om_cost = get_monthly_mistake_tuple()[0]
        week_cm_cost = get_monthly_mistake_tuple()[1]
        points_om_list = self.make_pairs(week_list, week_om_cost)
        points_cm_list = self.make_pairs(week_list, week_cm_cost)
        plot_om = SmoothLinePlot(
            color=[255 / 255.0, 125 / 255.0, 125 / 255.0, 1])
        plot_om.points = points_om_list
        plot_cm = SmoothLinePlot(
            color=[125 / 255.0, 177 / 255.0, 255 / 255.0, 1])
        plot_cm.points = points_cm_list

        # print("om:" + str(points_om_list)) #Blue
        # print("cm:" + str(points_cm_list)) # Red

        # week_mistakes = get_weekly_mistake_num()
        # points_list = self.make_pairs(week_list, week_mistakes)
        # print(points_list)

        plot = SmoothLinePlot(color=[1, 0, 0, 1])
        self.graph6.add_plot(plot_om)
        self.graph6.add_plot(plot_cm)
        self.ids['graph3'].remove_widget(self.graph7)
        self.ids['graph3'].remove_widget(self.graph5)
        self.ids['graph3'].add_widget(self.graph6)
 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 = SmoothLinePlot(color=[0.49, 0.98, 1, 1])
     with open("adclog.txt") as fh:
         coords = []
         for line in fh:
             line = line.strip('()\n')
             line = line.split(', ')
             c = tuple(float(x) for x in line)
             coords.append(c)
     plot.points = coords
     graph.add_plot(plot)
     self.add_widget(graph)
예제 #22
0
    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)
예제 #23
0
    def __init__(self, gui_base, **kwargs):
        # max number of points in a graph
        self.counter = 0
        self.max_points = 100

        self.values =  [deque(maxlen=self.max_points), deque(maxlen=self.max_points), deque(maxlen=self.max_points)]

        # By default, there are three graphs available
        self.graphs = [None, None, None]
        self.standard_graph_size = (.3, .15)
        self.standard_graph_size_labelled = (.312, .2105)

        self.graphs[0] = self.create_basic_graph('X', 0, 600, size_hint=self.standard_graph_size, pos_hint={"top": .98, "left": 1}, x_grid_label=False, xlabel='')
        self.graphs[1] = self.create_basic_graph('Y', -600, 200, size_hint=self.standard_graph_size, pos_hint={"top": .845, "left": 1}, x_grid_label=False, xlabel='')
        self.graphs[2] = self.create_basic_graph('Z', 1500, 2500, size_hint=self.standard_graph_size_labelled, pos_hint={"top": .71, "left": 1})

        # Each graph has one plot
        self.plots = [None, None, None]

        self.plots[0] = SmoothLinePlot(color=[1, 0, 0, 1])
        self.plots[1] = SmoothLinePlot(color=[0, 1, 0, 1])
        self.plots[2] = SmoothLinePlot(color=[0.6, 1, 1, 1])

        # Link plots to graphs
        self.graphs[0].add_plot(self.plots[0])
        self.graphs[1].add_plot(self.plots[1])
        self.graphs[2].add_plot(self.plots[2])

        # Add the graphs to the root
        gui_base.root.add_widget(self.graphs[0])
        gui_base.root.add_widget(self.graphs[1])
        gui_base.root.add_widget(self.graphs[2])
        self.root = gui_base.root

        self.hide_graphs()
        self.ready = True
예제 #24
0
파일: main.py 프로젝트: homdx/mohr
    def desenha_circulos(self, centro1, raio1, centro2, raio2, centro3, raio3):
        # circulo1
        self.plot_circulo1 = SmoothLinePlot(color=[1, 0, 0, 1])
        self.plot_circulo1.points = [
            (centro1 + raio1 * math.cos(theta * .01),
             raio1 * math.sin(theta * .01)) for theta in range(0, 1300)
        ]  # 130 => 40*pi (para dar 2 voltas completas)
        self.propriedade_grafico.add_plot(self.plot_circulo1)

        # circulo2
        self.plot_circulo2 = SmoothLinePlot(color=[0, 1, 0, 1])
        self.plot_circulo2.points = [
            (centro2 + raio2 * math.cos(theta * .01),
             raio2 * math.sin(theta * .01)) for theta in range(0, 1300)
        ]  # 130 => 40*pi (para dar 2 voltas completas)
        self.propriedade_grafico.add_plot(self.plot_circulo2)

        # circulo2
        self.plot_circulo3 = SmoothLinePlot(color=[0, 0, 1, 1])
        self.plot_circulo3.points = [
            (centro3 + raio3 * math.cos(theta * .01),
             raio3 * math.sin(theta * .01)) for theta in range(0, 1300)
        ]  # 130 => 40*pi (para dar 2 voltas completas)
        self.propriedade_grafico.add_plot(self.plot_circulo3)
예제 #25
0
 def delay(self,dt):
     self.plot_rpm = SmoothLinePlot(color=[1, 0, 0, 1])
     self.plot_tps = SmoothLinePlot(color=[0, 1, 0, 1])
     self.plot_iat = SmoothLinePlot(color=[0, 0, 1, 1])
     self.plot_map = SmoothLinePlot(color=[1, 1, 0, 1])
     self.plot_bat = SmoothLinePlot(color=[1, 0, 1, 1])
     self.plot_inj = SmoothLinePlot(color=[0, 1, 1, 1])
     self.plot_adv = SmoothLinePlot(color=[1, 1, 1, 1])
     self.AllPlot  ={        "rpm":self.plot_rpm,
                             "tps":self.plot_tps,
                             "iat":self.plot_iat,
                             "map":self.plot_map,
                             "bat":self.plot_bat,
                             "inj":self.plot_inj,
                             "adv":self.plot_adv
                             }
예제 #26
0
    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)
예제 #27
0
 def __init__(self, **kwargs):
     self.grid = True or kwargs['grid']
     self.color = kwargs['color']
     self.name = kwargs['name'].upper()
     self.label = kwargs['name']
     self.parent = kwargs['parent']
     self.gtype = kwargs['gtype']
     self.graph = Graph(ylabel=self.label,
                        x_ticks_minor=1,
                        x_ticks_major=5,
                        y_ticks_major=20,
                        x_grid_label=True,
                        y_grid_label=True,
                        padding=5,
                        x_grid=self.grid,
                        y_grid=self.grid,
                        xmin=0,
                        xmax=50,
                        ymin=0,
                        ymax=20)
     self.plot = SmoothLinePlot(color=self.color)
     self.plot.points = []
     self.graph.add_plot(self.plot)
예제 #28
0
파일: stats.py 프로젝트: chae9214/inversion
    def get_daily_mistakes(self):
        if self.flag == 4:
            return

        self.flag = 4

        day_list = days_to_ints(get_all_days())
        my_day_list = {}

        for (m, d) in day_list:
            if m in my_day_list:
                my_day_list[m].append(d)
            else:
                my_day_list[m] = []
                my_day_list[m].append(d)

        new_day_list = []

        for eachMonth in my_day_list:
            for eachDay in my_day_list[eachMonth]:
                new_day_list.append(eachDay + (eachMonth - 1) * 30)

        day_om_cost = get_daily_mistake_tuple()[0]
        day_cm_cost = get_daily_mistake_tuple()[1]
        points_om_list = self.make_pairs(new_day_list, day_om_cost)
        points_cm_list = self.make_pairs(new_day_list, day_cm_cost)
        plot_om = SmoothLinePlot(
            color=[255 / 255.0, 125 / 255.0, 125 / 255.0, 1])
        plot_om.points = points_om_list
        plot_cm = SmoothLinePlot(
            color=[125 / 255.0, 177 / 255.0, 255 / 255.0, 1])
        plot_cm.points = points_cm_list

        print("om:" + str(points_om_list))  #Blue
        print("cm:" + str(points_cm_list))  # Red

        self.graph7.add_plot(plot_om)
        self.graph7.add_plot(plot_cm)
        self.ids['graph3'].remove_widget(self.graph5)
        self.ids['graph3'].remove_widget(self.graph6)
        self.ids['graph3'].add_widget(self.graph7)
예제 #29
0
        def build(self):
            layout = BoxLayout(orientation='vertical')

            graph_theme = {
                'label_options': {
                    'color': rgb('444444'),  # color of tick labels and titles
                    'bold': True
                },
                'background_color':
                rgb('f8f8f2'),  # back ground color of canvas
                'tick_color': rgb('808080'),  # ticks and grid
                'border_color': rgb('808080')
            }  # border drawn around each graph

            x_values = list(range(100))
            y_values = [123.0 + random() for x in x_values]
            end_date = date(2017, 2, 1)
            one_day = timedelta(1)
            date_values = [end_date - one_day * i for i in x_values]
            date_values.reverse()
            time_series = zip(x_values, y_values)

            graph1 = TimeSeriesGraph(
                date_values,
                date_label_format='%b',
                xlabel='example 1',
                ylabel='some y labels',
                #x_ticks_minor=5,
                x_ticks_major='month',
                y_ticks_major=0.1,
                y_grid_label=True,
                x_grid_label=True,
                padding=5,
                xlog=False,
                ylog=False,
                x_grid=True,
                y_grid=True,
                #xmin=-50,
                #xmax=50,
                ymin=123,
                ymax=124,
                font_size='12sp',
                **graph_theme)

            plot1 = SmoothLinePlot(color=rgb('7dac9f'))
            plot1.points = time_series
            graph1.add_plot(plot1)

            plot3 = SmoothLinePlot(color=rgb('dc7062'))
            y_values = [123.0 + random() for x in x_values]
            time_series = zip(x_values, y_values)
            plot3.points = time_series
            graph1.add_plot(plot3)

            layout.add_widget(graph1)

            y_values = [123.0 + random() for x in x_values]

            graph2 = TimeSeriesGraph(
                date_values,
                date_label_format='%b-%d',
                xlabel='example 2',
                ylabel='some y labels',
                x_ticks_minor=5,
                x_ticks_major=30,
                y_ticks_major=0.1,
                y_grid_label=True,
                x_grid_label=True,
                padding=5,
                xlog=False,
                ylog=False,
                x_grid=True,
                y_grid=True,
                #xmin=-50,
                #xmax=50,
                ymin=123,
                ymax=124,
                font_size='12sp',
                **graph_theme)

            plot2 = SmoothLinePlot(color=rgb('7dac9f'))
            plot2.points = zip(x_values, y_values)
            graph2.add_plot(plot2)

            layout.add_widget(graph2)

            s = Screen(name="test1")
            s.add_widget(layout)

            sm = ScreenManager()
            sm.add_widget(s)

            return sm
예제 #30
0
    def build(self):
        self.lplot = SmoothLinePlot(color=COLOR_RED)
        self.graph.add_plot(self.lplot)

        self.rplot = SmoothLinePlot(color=COLOR_BLUE)
        self.graph.add_plot(self.rplot)
예제 #31
0
    def __init__(self, **kwargs):
        super(RobRehabGUI, self).__init__(**kwargs)

        self.configStorage = JsonStore('config.json')
        if self.configStorage.exists('server'):
            self.ids['address_input'].text = self.configStorage.get(
                'server')['address']
        if self.configStorage.exists('user'):
            self.ids['user_name_input'].text = self.configStorage.get(
                'user')['name']

        self.robotSelector = self.ids['robot_selector']
        self.robotEntries = DropDown()
        self.robotEntries.bind(
            on_select=lambda instance, name: self.SetRobot(name))
        self.robotSelector.bind(on_release=self.robotEntries.open)
        self.axisSelector = self.ids['axis_selector']
        self.axisEntries = DropDown()
        self.axisEntries.bind(
            on_select=lambda instance, name: self.SetAxis(name))
        self.axisSelector.bind(on_release=self.axisEntries.open)

        self.enableToggle = self.ids['enable_button']
        self.offsetToggle = self.ids['offset_button']
        self.calibrationToggle = self.ids['calibration_button']
        self.operationToggle = self.ids['operation_button']

        self.measureSlider = self.ids['measure_slider']
        self.setpointSlider = self.ids['setpoint_slider']
        self.forceSlider = self.ids['force_slider']
        self.inertiaSlider = self.ids['inertia_slider']
        self.stiffnessSlider = self.ids['stiffness_slider']
        self.dampingSlider = self.ids['damping_slider']

        self.motionSelector = self.ids['motion_selector']
        self.motionEntries = DropDown()
        self.motionEntries.bind(
            on_select=lambda instance, name: self.SetMotion(name))
        self.motionSelector.bind(on_release=self.motionEntries.open)
        setpointMotions = []
        for fileName in os.listdir(self.MOTIONS_DIR):
            if fileName.endswith('.txt'):
                setpointMotions.append(os.path.splitext(fileName)[0])
        self._UpdateSelectorEntries(self.motionSelector, self.motionEntries,
                                    setpointMotions)
        self.SetMotion(self.DEFAULT_MOTION)

        self.setpointUpdateEvent = None

        dataGraph = self.ids['data_graph']

        measure_range = self.measureSlider.range
        GRAPH_PROPERTIES = {
            'x_ticks_minor': 5,
            'x_ticks_major': 25,
            'y_ticks_minor': 0.25,
            'y_ticks_major': 0.5,
            'y_grid_label': True,
            'x_grid_label': True,
            'padding': 5,
            'x_grid': True,
            'y_grid': True,
            'xmin': 0,
            'xmax': len(self.INITIAL_VALUES) - 1,
            'background_color': [1, 1, 1, 1],
            'tick_color': [0, 0, 0, 1],
            'border_color': [0, 0, 0, 1],
            'label_options': {
                'color': [0, 0, 0, 1],
                'bold': True
            }
        }

        axisPositionGraph = Graph(ylabel='Position/Setpoint',
                                  ymin=measure_range[0],
                                  ymax=measure_range[1],
                                  **GRAPH_PROPERTIES)
        positionPlot = SmoothLinePlot(color=[0, 0, 1, 1])
        axisPositionGraph.add_plot(positionPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(positionPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_POSITION))
        velocityPlot = SmoothLinePlot(color=[0, 1, 0, 1])
        axisPositionGraph.add_plot(velocityPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(velocityPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_VELOCITY))
        accelerationPlot = SmoothLinePlot(color=[1, 1, 0, 1])
        axisPositionGraph.add_plot(accelerationPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(accelerationPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_ACCELERATION))
        refPositionPlot = SmoothLinePlot(color=[0, 0, 0.5, 1])
        axisPositionGraph.add_plot(refPositionPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(refPositionPlot, self.INITIAL_VALUES[:],
                                 self.setpoints, DOF_POSITION))
        dataGraph.add_widget(axisPositionGraph)

        dataGraph.add_widget(Label(size_hint_y=0.05))

        force_range = self.forceSlider.range
        axisForceGraph = Graph(ylabel='Force/Impedance',
                               ymin=force_range[0],
                               ymax=force_range[1],
                               **GRAPH_PROPERTIES)
        forcePlot = SmoothLinePlot(color=[1, 0, 0, 1])
        axisForceGraph.add_plot(forcePlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(forcePlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_FORCE))
        dampingPlot = SmoothLinePlot(color=[0, 0, 1, 1])
        axisForceGraph.add_plot(dampingPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(dampingPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_DAMPING))
        inertiaPlot = SmoothLinePlot(color=[0, 1, 0, 1])
        axisForceGraph.add_plot(inertiaPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(inertiaPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_INERTIA))
        stiffnessPlot = SmoothLinePlot(color=[1, 1, 0, 1])
        axisForceGraph.add_plot(stiffnessPlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(stiffnessPlot, self.INITIAL_VALUES[:],
                                 self.measures, DOF_STIFFNESS))
        refForcePlot = SmoothLinePlot(color=[0.5, 0, 0, 1])
        axisForceGraph.add_plot(refForcePlot)
        self.dataPlots.append(
            RobRehabGUI.DataPlot(refForcePlot, self.INITIAL_VALUES[:],
                                 self.setpoints, DOF_FORCE))
        dataGraph.add_widget(axisForceGraph)

        dataGraph.add_widget(Label(text='Last Samples', size_hint_y=0.1))

        Clock.schedule_interval(self.DataUpdate, self.UPDATE_INTERVAL / 2)
        Clock.schedule_interval(self.GraphUpdate, self.UPDATE_INTERVAL * 2)
        Clock.schedule_interval(self.SliderUpdate, self.UPDATE_INTERVAL)
예제 #32
0
파일: main.py 프로젝트: homdx/mohr
 def desenha_linha(self, xstress, ystress, xyshear):
     self.plot_linha_inicial = SmoothLinePlot(color=[0, 1, 0, 1])
     self.plot_linha_inicial.points = [(xstress, xyshear),
                                       (ystress, -xyshear)]
     self.propriedade_grafico.add_plot(self.plot_linha_inicial)
예제 #33
0
    def graph(self):
        soln_graph = screen_manager.get_screen('solution').layout

        fx = Fx(shunt(self.eq)).eval
        colors = itertools.cycle([
            rgb('dc7062'),
            rgb('fff400'),
            rgb('7dac9f'),
            rgb('66a8d4'),
            rgb('e5b060')
        ])

        fxplot = SmoothLinePlot(color=next(colors))

        for i in range(-500, 501):
            x = i / 10.
            y = fx(x)
            fxplot.points.append((x, y))
        soln_graph.graph.add_plot(fxplot)

        if self.solutions:
            plot = MeshLinePlot(color=rgb('fff400'))

            xmin = float(round(self.solutions[0], 4))
            xmax = float(xmin)

            ymin = fx(xmin)
            ymax = ymin

            xmin = xmin
            xmax = xmin

            Logger.info("Plotting")

            plotx = MeshLinePlot(color=next(colors))
            plotx.points = [(float(x), fx(x)) for x in self.solutions]

            counter = len(self.solutions)
            while counter >= 3:
                Logger.info(counter)
                for index in range(min(3, counter)):
                    x = round(float(self.solutions[index]), 4)
                    y = round(float(fx(x)), 4)
                    x = x

                    xmin = float(min([xmin, x]))
                    xmax = float(max([xmax, x]))

                    ymin = float(min([ymin, y]))
                    ymax = float(max([ymax, y]))

                    plot.points.append((x, y))
                    counter = counter - 1
                    if len(plot.points) >= min(3, len(self.solutions)):
                        Logger.debug(['pts', plot.points])
                        soln_graph.graph.add_plot(plot)
                        plot = MeshLinePlot(color=next(colors))
                        self.solutions.pop(0)
                        counter = len(self.solutions)
                        break

        pad = 0.1
        Logger.debug(plot.points)
        soln_graph.graph.xmin = round(xmin - pad, 1)
        soln_graph.graph.xmax = round(xmax + pad, 1)

        soln_graph.graph.ymin = round(ymin - pad, 2)
        soln_graph.graph.ymax = round(ymax + pad, 2)

        hbar = MeshLinePlot(color=[1, 1, 1, 1])
        hbar.points.append((soln_graph.graph.xmin, 0))
        hbar.points.append((soln_graph.graph.xmax, 0))
        soln_graph.graph.add_plot(hbar)

        for x, y in plotx.points:
            vbar = MeshLinePlot(color=rgb('6d98e2'))
            vbar.points.append((x, 0))
            vbar.points.append((x, y))
            soln_graph.graph.add_plot(vbar)