Пример #1
0
 def __init__(self, *args, **kwargs):
     super(MainWindow, self).__init__(*args, **kwargs)
     self.plot_p = LinePlot(line_width=1.1, color=[1, 0, 0, 1])
     self.plot_f = LinePlot(line_width=1.1, color=[0.5, 1, 0.5, 1])
     self.plot_v = LinePlot(line_width=1.1, color=[0, 0.55, 0.8, 1])
     self.parameters = VentilatorParams()
     Clock.schedule_interval(self.update, 1 / 100.0)
Пример #2
0
 def total_value_plot(self):
     """
     display total value of stocks
     :return: none
     """
     self.plot = LinePlot(color=[0, 1, 0, 1])
     self.plot.points = DisplayGraphs().total_val()
     self.ids.graph.add_plot(self.plot)
Пример #3
0
class StockGraph(BoxLayout):
    """
    Displays the graphs
    on start graph == total portfolio value / time
    TODO: integrate OHLCV candlestick for each stock
    TODO: Integrate log returns
    """
    graph = ObjectProperty(None)

    def __init__(self, **kwargs):
        super(StockGraph, self).__init__(**kwargs)
        # DisplayGraphs()
        self.plot = None
        self.total_value_plot()

    def total_value_plot(self):
        """
        display total value of stocks
        :return: none
        """
        self.plot = LinePlot(color=[0, 1, 0, 1])
        self.plot.points = DisplayGraphs().total_val()
        self.ids.graph.add_plot(self.plot)

    def candle_stick_plot(self, stock, table):
        """
        Display OHLC candlestick graph
        :param stock: stock symbol
        :param table: Stocks/Crypto
        :return: None
        """
        self.ids.graph.remove_plot(self.plot)
        points = DisplayGraphs().candle_stick(stock, table)
        # self.plot = mpf.plot(points, type='candle', title=stock, figsize=(1, 1), volume=True)

        fig, ax = plt.subplot()
        # fig.size = 0.75, 0.75

        # Setting labels & titles
        ax.set_xlabel('Date')
        self.plot.ylabel('Price')
        # sticks = mpf.plot(points, type='candle', title=stock, figsize=(1, 1), volume=True)
        # print(sticks.__sizeof__())
        # plot.points = sticks
        self.add_widget(FigureCanvasKivyAgg(figure=fig))

    def on_press(self):
        """
        TODO: Volume? another graph? remove to make graph larger?
        currently prints the
        :return:
        """
        stocks, crypto = StockEditor().list_stocks()
        print(DisplayGraphs().total_val())
Пример #4
0
 def DataGraphGiro(self, xmax, plot_color, plot_color_y, plot_color_z, **kwargs):
     """
     Método para a criação do grafico com dados do giroscopio.
     """
     plot = LinePlot(line_width = 1.5, color = plot_color)
     plot2 = LinePlot(line_width = 1.5, color = plot_color_y)
     plot3 = LinePlot(line_width = 1.5, color = plot_color_z)
     self.ids.graphGiroscopio.add_plot(plot)
     self.ids.graphGiroscopio.add_plot(plot2)
     self.ids.graphGiroscopio.add_plot(plot3)
     self.ids.graphGiroscopio.xmax = xmax
Пример #5
0
    def __init__(self, **kwargs):
        """self.graph ne peut pas être initié ici.
        Il doit être dans une autre méthode et appelé plus tard.
        """

        super().__init__(**kwargs)

        self.sensor_id = None
        self.unit_x = ""
        self.unit_y = ""
        self.graph = None
        self.histo = []
        self.histo_data = None
        self.y_major = 0
        self.titre = "Capteur"
        self.reset = None
        self.xlabel = ""
        self.duration = None

        # Initialisation de la courbe avec sa couleur
        self.curve_plot = MeshLinePlot(color=[0, 0, 0, 1])
        self.curve_plot.points = [(0, 0)]*101

        # horizontal_line
        self.line_plot = LinePlot(line_width=2, color=[1, 0, 0.5, 1])

        # Appel tous les 2 secondes
        Clock.schedule_interval(self.update, 2)
Пример #6
0
    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 = LinePlot(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.)
Пример #7
0
 def yap(self, za):
     box = self.ids.deneme
     graph_theme = {
         'label_options': {
             'color': rgb('444444'),  # color of tick labels and titles
             'bold': True
         },
         'background_color': rgb('2b2b2b'),  # canvas background color
         'tick_color': rgb('7ba21d'),  # ticks and grid
         'border_color': rgb('000000')
     }  # border drawn around each graph
     self.graph = Graph(
         xlabel='Time (s)',
         ylabel='Temparature (°F)',
         x_ticks_major=10,
         y_ticks_major=10,
         y_grid_label=True,
         x_grid_label=True,
         padding=5,
         #xmin=0,
         #ymin=0,
         **graph_theme)
     box.add_widget(self.graph)
     self.plot = LinePlot(line_width=2, color=[0.48, 0.63, 0.11, 1])
     self.graph.add_plot(self.plot)
     self.salise = 0
     self.saniye = 0
     self.dakika = 0
     self.values = []
    def __init__(self, *a, **kw):
        super().__init__(*a, **kw)

        self.theme_cls.primary_palette = 'Red'
        self.theme_cls.primary_hue = '700'
        # self.theme_cls.theme_style = 'Dark'

        self._countries_data = get_countries_data()

        self._cases_plot = LinePlot(color=(1, 0, 0, 1), line_width=(1.3))

        self.data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=222,
            column_data=[
                ("No", dp(10)),
                ("Country", dp(40)),
                ("Total Cases", dp(30)),
            ],
            row_data=self.set_row_data()[0],
            sort=True,
            on_row_press=self.on_row_pressed_,
        )
        self.country_dialog = MDDialog(
                    title='Select A Country',
                    type='custom',
                    size_hint=(.8, .9),
                    content_cls=MyList(items=[MyListItem(id=idx, text=val, on_press=lambda e: self.on_select_country(e.id)) \
                            for idx, val in enumerate(self.set_row_data()[1])])
            )
Пример #9
0
    def create_plot(self):
        x2 = self.x2_variable
        plot = self.plot
        if plot is not None:
            if (x2 and isinstance(plot, ContourPlot)
                    or not x2 and isinstance(plot, LinePlot)):
                return
            self.graph.remove_plot(plot)

        for plot in self._contour_plots:
            self.graph.remove_plot(plot)
            self._contour_plots = []

        self._yvals = None
        yvar = x2 or self.y_variable
        graph_theme = {
            'label_options': {
                'color': rgb('444444'),
                'bold': True
            },
            # 'background_color': rgb('f8f8f2'),
            'tick_color':
            rgb('808080'),
            'border_color':
            rgb('808080'),
            'xlabel':
            '{} -- {}'.format(
                self.x_variable_formula.widget.name,
                self.formula.variable_descriptions.get(self.x_variable,
                                                       self.x_variable)),
            'ylabel':
            self.formula.variable_descriptions.get(yvar, yvar),
            'x_ticks_minor':
            5,
            # 'y_ticks_minor': 5,
            'y_grid_label':
            True,
            'x_grid_label':
            True,
            'padding':
            5,
            'x_grid':
            True,
            'y_grid':
            True,
        }

        graph = self.graph
        for k, v in graph_theme.items():
            setattr(graph, k, v)

        if x2:
            self.plot = plot = ContourPlot(color=next(self.colors))
        else:
            self.plot = plot = LinePlot(color=next(self.colors), line_width=2)
        graph.add_plot(plot)

        self._value_plot = PointPlot(color=next(self.colors), point_size=3)
        graph.add_plot(self._value_plot)
Пример #10
0
 def DataGraph(self, xmax, plot_color, **kwargs):
     """
     Método para a criação do grafico de Altitude
     """
     # super().__init__(**kwargs)
     plot = LinePlot(line_width = 1.5, color = plot_color)
     self.ids.graphAltitude.add_plot(plot)
     self.ids.graphAltitude.xmax = xmax
Пример #11
0
    def update_plot(self):
        if not db[self.rec_idx]['one_way']:
            plot = LinePlot(line_width=2, color=[0, 0, 1, 1])
            plot2 = LinePlot(line_width=2, color=[1, 0, 0, 1])
            plot.points = ((i, v) for i, v in enumerate(db[
                self.rec_idx]['trip_data']['to'].values()))
            plot2.points = ((i, v) for i, v in enumerate(db[
                self.rec_idx]['trip_data']['back'].values()))
            min1 = min(plot.points, key=lambda t: t[1])[1]
            min2 = min(plot2.points, key=lambda t: t[1])[1]
            max1 = max(plot.points, key=lambda t: t[1])[1]
            max2 = max(plot2.points, key=lambda t: t[1])[1]
            last_out = plot.points[-1][1]
            last_in = plot2.points[-1][1]
            self.show_info(min1=min1,
                           min2=min2,
                           max1=max1,
                           max2=max2,
                           last_out=last_out,
                           last_in=last_in)
            self.graph.xmax = len(plot.points)

            if min1 < min2 or min1 == min2:
                min1 = (min1 * 0.9) - (min1 * 0.9) % 10
                self.graph.ymin = min1
            else:
                min2 = (min2 * 0.9) - (min2 * 0.9) % 10
                self.graph.ymin = min2

            if max1 > max2 or max1 == max2:
                self.graph.ymax = max1 + 25
            else:
                self.graph.ymax = max2 + 25
            self.graph.add_plot(plot)
            self.graph.add_plot(plot2)
        else:

            plot = LinePlot(line_width=2, color=[0, 0, 1, 1])
            plot.points = ((i, v) for i, v in enumerate(db[
                self.rec_idx]['trip_data']['to'].values()))
            min1 = min(plot.points, key=lambda t: t[1])[1]
            max1 = max(plot.points, key=lambda t: t[1])[1]
            last_out = plot.points[-1][1]
            self.show_info(min1=min1, max1=max1, last_out=last_out)
            self.graph.xmax = len(plot.points)
            min1 = (min1 * 0.9) - (min1 * 0.9) % 10
            self.graph.ymin = min1
            self.graph.ymax = max1 + 25

            self.graph.add_plot(plot)
Пример #12
0
    def make_plot(self, prices):
        """
        Make plot area of the graph.

        :param prices: A (t x k) price matrix with t timesteps and k prices.
        :type prices: numpy.ndarray
        """
        self.plot_1 = LinePlot(line_width=2, color=[1, 0, 0, 1])
        self.plot_1.points = [
            (x, y) for x, y in enumerate(list(prices[:, 1] / prices[:, 0]))
        ]
        self.add_plot(self.plot_1)

        self.plot_2 = LinePlot(line_width=2, color=[0, 1, 0, 1])
        self.plot_2.points = [
            (x, y) for x, y in enumerate(list(prices[:, 2] / prices[:, 0]))
        ]
        self.add_plot(self.plot_2)
Пример #13
0
 def plot_data(self, data):
     """
     Change the data shown on the stock graph.
     data should be a list of tuples showing (x,y) pairs on the graph.
     """
     self.graph.ymax = max(price for _,price in data) * 1.01
     self.graph.ymin = min(price for _,price in data) * .99
     self.graph.y_ticks_major = (self.graph.ymax - self.graph.ymin) / 4
     self.graph.remove_plot(self.plot)
     self.plot = LinePlot(color=WHITE, line_width=3)
     self.plot.points = data
     self.graph.add_plot(self.plot)
Пример #14
0
 def __init__(self, **kwargs):
     super(GraphWidget, self).__init__(**kwargs)
     
     # if 'plotColor' in kwargs:
     #     self.plotColor = kwargs['plotColor']
     # else:
     #     self.plotColor = [1, 0, 0, 1]
     self.plot = LinePlot(color=self.plotColor, line_width=1)
     self.plot.points = [(x/50, nan) for x in range(0, 500)]
     self.insertIndex = 0
     self.add_plot(self.plot)
     self.filter = None
Пример #15
0
    def _initplot(self):
        self.label_options = {'color': rgb('#FF0000'), 'bold': True}
        self.background_color = rgb('f8f8f2')
        self.tick_color = rgb('808080')
        self.border_color = rgb('808080')
        self.xlabel = 'X'
        self.ylabel = 'Y'
        self.x_ticks_minor = 5
        self.x_ticks_major = 25
        self.y_ticks_major = 10
        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 = self._num_datapoints
        self.ymin = 20
        self.ymax = 80
        self.show_setpoint = True

        self.plot = LinePlot(color=[0, 0, 1, 1],
                             line_width=2)  # , color=[1, 0, 0, 1])
        x = [x for x in range(0, 101)]

        y = [random() for x in range(0, 101)]
        # self.plot.points  = [(x, random()) for x in range(0, 101)]
        plot_data = list(zip(x, self._temp))
        # plot_data = list(zip(self._time, self._temp))

        self.plot.points = plot_data
        self.add_plot(self.plot)

        if self.show_setpoint:
            self.setpoint_plot = LinePlot(
                color=[1, 0, 0, 1], line_width=2)  # , color=[1, 0, 0, 1])
            self.setpoint_plot.points = plot_data
            self.add_plot(self.setpoint_plot)
Пример #16
0
    def _initplot(self):
        self.label_options = {'color': rgb('#FF0000'), 'bold': True}
        self.background_color = rgb('f8f8f2')
        self.tick_color = rgb('808080')
        self.border_color = rgb('808080')
        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 = -1
        self.ymax = 1

        self.plot = LinePlot(line_width=4, color=[1, 0, 0, 1])
        self.plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
        self.add_plot(self.plot)
Пример #17
0
 def __init__(self, *args, **kwargs):
     super(MainScreen, self).__init__(*args, **kwargs)
     self.plot_p = LinePlot(line_width=1.5, color=[1, 0, 0, 1])
     self.plot_f = LinePlot(line_width=2, color=[0.5, 1, 0.5, 1])
     self.plot_v = LinePlot(line_width=2, color=[0, 0.55, 0.8, 1])
     Clock.schedule_interval(self.update, 0.01)
Пример #18
0
    def __init__(self, **kwargs):
        super(graphicsScreen, self).__init__(**kwargs)

        global dataFile
        self.dataFile = dataFile
        global refreshRate
        self.refreshRate = refreshRate
        Window.size = (800, 600)
        self.cols = 2
        self.rows = 2

        ############################ SCORE ##################################################
        self.graphScore = Graph(xlabel='Generation',
                                ylabel='Score',
                                font_size='20sp',
                                x_ticks_major=1,
                                y_ticks_major=1,
                                y_grid_label=True,
                                x_grid_label=True,
                                padding=5,
                                xlog=False,
                                ylog=False,
                                x_grid=True,
                                y_grid=True,
                                ymin=0,
                                xmin=0)

        self.scorePlot = LinePlot(color=[1, 0, 0, 1], line_width=2)
        self.scorePlotMedian = LinePlot(color=[0.3, 0.3, 1, 1], line_width=2)
        self.scorePlot.points = [(0, 0)]
        self.scorePlotMedian.points = [(0, 0)]
        self.graphScore.add_plot(self.scorePlot)
        self.graphScore.add_plot(self.scorePlotMedian)

        ############################ FITNESS ##################################################
        self.graphFitness = Graph(xlabel='Generation',
                                  ylabel='Fitness',
                                  font_size='20sp',
                                  x_ticks_major=1,
                                  y_ticks_major=1,
                                  y_grid_label=True,
                                  x_grid_label=True,
                                  padding=5,
                                  xlog=False,
                                  ylog=False,
                                  x_grid=True,
                                  y_grid=True,
                                  ymin=0,
                                  xmin=0)

        self.fitnessPlot = LinePlot(color=[1, 0, 0, 1], line_width=2)
        self.fitnessPlotMedian = LinePlot(color=[0.3, 0.3, 1, 1], line_width=2)
        self.fitnessPlot.points = [(0, 0)]
        self.fitnessPlotMedian.points = [(0, 0)]
        self.graphFitness.add_plot(self.fitnessPlot)
        self.graphFitness.add_plot(self.fitnessPlotMedian)

        ############################ SCORE TIME ##################################################
        self.graphScoreTime = Graph(xlabel='Time [min]',
                                    ylabel='Score',
                                    font_size='20sp',
                                    x_ticks_major=1,
                                    y_ticks_major=1,
                                    y_grid_label=True,
                                    x_grid_label=True,
                                    padding=5,
                                    xlog=False,
                                    ylog=False,
                                    x_grid=True,
                                    y_grid=True,
                                    ymin=0,
                                    xmin=0)

        self.scoreTimePlot = LinePlot(color=[1, 0, 0, 1], line_width=2)
        self.scoreTimePlotMedian = LinePlot(color=[0.3, 0.3, 1, 1],
                                            line_width=2)
        self.scoreTimePlot.points = [(0, 0)]
        self.scoreTimePlotMedian.points = [(0, 0)]
        self.graphScoreTime.add_plot(self.scoreTimePlot)
        self.graphScoreTime.add_plot(self.scoreTimePlotMedian)

        ############################ GENERATION TIME ##################################################
        self.graphGenTime = Graph(xlabel='Generation',
                                  ylabel='Time [min]',
                                  font_size='20sp',
                                  x_ticks_major=1,
                                  y_ticks_major=1,
                                  y_grid_label=True,
                                  x_grid_label=True,
                                  padding=5,
                                  xlog=False,
                                  ylog=False,
                                  x_grid=True,
                                  y_grid=True,
                                  ymin=0,
                                  xmin=0)

        self.genTimePlot = LinePlot(color=[1, 0, 0, 1], line_width=2)
        self.genTimePlot.points = [(0, 0)]
        self.graphGenTime.add_plot(self.genTimePlot)

        self.add_widget(self.graphScore)
        self.add_widget(self.graphFitness)
        self.add_widget(self.graphScoreTime)
        self.add_widget(self.graphGenTime)

        if self.refreshRate > 0:
            self.readHandle = Clock.schedule_interval(self.readPipeData,
                                                      self.refreshRate)
        else:
            self.readCsvData()
Пример #19
0
    def __init__(self, **kwargs):
        super(MainScreen, self).__init__(**kwargs)

        #Set the number of columns
        self.cols = 3

        #Heading
        self.add_widget(Label(size_hint=(1, 0.5)))
        self.heading = Label(size_hint=(1, 0.5))
        self.heading.font_size = 30
        self.heading.text = "Automatic Blinds & Live Weather"
        self.heading.bold = True

        self.add_widget(self.heading)
        self.add_widget(Label(size_hint=(1, 0.5)))

        #Current temperature label
        self.tempLabel = Label(size_hint=(1, 0.05))
        self.add_widget(self.tempLabel)

        self.add_widget(Label(size_hint=(1, 0.05)))

        #Current Humidity Label
        self.humLabel = Label(size_hint=(1, 0.05))
        self.add_widget(self.humLabel)

        #Graph theme
        graph_theme = {
            'background_color': (0, 0, 0, 0),
            'tick_color': (128 / 255, 128 / 255, 128 / 255, 1)
        }

        #Temperature Graph
        self.tempGraph = Graph(xlabel='Time',
                               ylabel='Temperature',
                               x_ticks_minor=5,
                               x_ticks_major=10,
                               y_ticks_minor=1,
                               y_ticks_major=5,
                               x_grid_label=True,
                               y_grid_label=True,
                               padding=5,
                               x_grid=True,
                               y_grid=True,
                               xmin=-0,
                               xmax=60,
                               ymin=-0,
                               ymax=50,
                               size_hint=(3, 1),
                               **graph_theme)

        #Temperature plot (where to send the data points)
        self.tempPlot = LinePlot(color=(64 / 255, 224 / 255, 208 / 255, 1),
                                 line_width=1.5)
        self.tempGraph.add_plot(self.tempPlot)

        self.add_widget(self.tempGraph)

        self.add_widget(Label())

        #Humidity Graph
        self.humGraph = Graph(xlabel='Time',
                              ylabel='Humidity',
                              x_ticks_minor=5,
                              x_ticks_major=10,
                              y_ticks_minor=1,
                              y_ticks_major=10,
                              x_grid_label=True,
                              y_grid_label=True,
                              padding=5,
                              x_grid=True,
                              y_grid=True,
                              xmin=-0,
                              xmax=60,
                              ymin=-0,
                              ymax=100,
                              size_hint=(3, 1),
                              **graph_theme)

        #Humidity plot (where to send the data points)
        self.humPlot = LinePlot(color=(64 / 255, 224 / 255, 208 / 255, 1),
                                line_width=1.5)

        self.humGraph.add_plot(self.humPlot)

        self.add_widget(self.humGraph)

        self.add_widget(Label())

        #Config button, sends you to the config screen
        self.button = Button(text="Configure",
                             font_size=30,
                             bold=True,
                             size_hint=(3, 1))
        self.add_widget(self.button)

        #Starts a thread which collects the data from the sensor, then graphs it using 'PlotTempHum'
        _thread.start_new_thread(sensors.graphDHT11, (self.PlotTempHum, ))
Пример #20
0
 def __init__(self, **kwargs):
     super(Logic, self).__init__(**kwargs)
     self.plot = LinePlot(line_width=2, color=[1, 0, 0, 1])
     self.plot2 = LinePlot(line_width=2,color=[0, 1, 0, 1])
     self.plot3 = LinePlot(line_width=2,color=[0, 0, 1, 1])
Пример #21
0
 def __init__(self, xmax, plot_color, **kwargs):
     super().__init__(**kwargs)
     self.plot = LinePlot(line_width=1.5, color=plot_color)
     self.ids.graph.add_plot(self.plot)
     self.ids.graph.xmax = xmax