Esempio n. 1
0
    def create_graph(self, dates):
        if len(dates) > 0:
            graph = Graph(x_ticks_minor=5,
                          y_ticks_minor=5,
                          x_ticks_major=5,
                          y_ticks_major=5,
                          y_grid_label=True,
                          x_grid_label=True,
                          padding=5,
                          border_color=[0, 0, 0, 0],
                          font_size=8,
                          xmin=0,
                          xmax=calendar.monthrange(dates[0].year,
                                                   dates[0].month)[1],
                          ymin=int(min([x.weight for x in dates]) - 5),
                          ymax=int(max([x.weight for x in dates]) + 5))
        else:
            graph = Graph(x_ticks_minor=5,
                          y_ticks_minor=5,
                          x_ticks_major=5,
                          y_ticks_major=5,
                          y_grid_label=True,
                          x_grid_label=True,
                          padding=5,
                          border_color=[0, 0, 0, 0],
                          font_size=8,
                          xmin=0,
                          ymin=0)

        plot = SmoothLinePlot(color=[1, 105 / 255, 97 / 255, 1])
        plot.points = [(x.day, float(x.weight)) for x in dates]
        graph.add_plot(plot)

        return graph
Esempio n. 2
0
    def create_graph(self):
        colors = itertools.cycle([
            rgb('7dac9f'), rgb('dc7062'), rgb('66a8d4'), rgb('e5b060')
        ])
        graph_theme = {
            'label_options': {
                'color': (0, 0, 0, 1),
                'bold': False},
            'background_color': (.9, .9, .9, 1),
            'tick_color': rgb('808080'),
            'border_color': rgb('808080')
        }
        graph = Graph(xlabel='',
                      ylabel='Glicemia',
                      font_size=14,
                      x_ticks_minor=0,
                      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,
                      **graph_theme)

        #plot = MeshLinePlot(color=[1, 0, 0, 1])
        plot = MeshLinePlot(color=next(colors))
        plot.points = [(x, sin(x/10.)) for x in range(0, 101)]
        graph.add_plot(plot)
        return graph
Esempio n. 3
0
    def __init__(self, ticker):
        self.CurrentPrice = 100
        self.ticker = ticker
        self.cryptos = []
        self.yticks = 100

        self.xticks = 10
        self.xmax = 50
        self.chart = Graph(
            xlabel='Time',
            ylabel='Price',
            x_ticks_minor=0,
            x_ticks_major=self.xticks,
            y_ticks_major=self.yticks,
            y_grid_label=True,
            x_grid_label=True,
            padding=5,
            x_grid=True,
            y_grid=True,
            xmin=0,
            xmax=self.xmax,
            ymin=0,
        )

        self.plot = SmoothLinePlot(color=[1, 1, 1, 1])
        self.chart.add_plot(self.plot)
Esempio n. 4
0
    def create_graph(self):
        print("Création du graph ...")
        if self.graph:
            self.ids.graph_id.remove_widget(self.graph)

        xmin = self.get_xmin()

        self.graph = Graph(background_color=(0.8, 0.8, 0.8, 1),
                           border_color=(0, 0.1, 0.1, 1),
                           xlabel=self.xlabel,
                           ylabel=self.ylabel,
                           x_ticks_minor=self.x_ticks_minor,
                           x_ticks_major=self.x_ticks_major,
                           y_ticks_major=self.y_ticks_major,
                           x_grid_label=True,
                           y_grid_label=True,
                           padding=10,
                           x_grid=True,
                           y_grid=True,
                           xmin=xmin,
                           xmax=self.xmax,
                           ymin=self.ymin,
                           ymax=self.ymax,
                           tick_color=(1, 0, 1, 1),
                           label_options={'color': (0.2, 0.2, 0.2, 1)})

        self.graph.add_plot(self.curve_x)
        self.graph.add_plot(self.curve_y)
        self.graph.add_plot(self.curve_z)
        self.ids.graph_id.add_widget(self.graph)
Esempio n. 5
0
def make_plot(plot_price,
              plot_dates,
              tickers_on_plot,
              plot_colors,
              xlabel='Bitcoin'):
    x = list(range(1, (len(plot_price) + 1)))
    y = plot_price
    y_axis_ticks = (max(y) - min(y)) / 5
    plot = None
    graph = Graph(xlabel=xlabel,
                  x_ticks_major=1,
                  y_ticks_major=y_axis_ticks,
                  y_grid_label=True,
                  x_grid_label=True,
                  padding=10,
                  x_grid=False,
                  y_grid=False,
                  xmin=min(x),
                  xmax=max(x),
                  ymin=min(y),
                  ymax=max(y))

    for i in range(0, len(tickers_on_plot)):
        plot = MeshLinePlot(color=plot_colors[i])
        plot.points = [(i, j) for i, j in zip(x, (y))]
        graph.add_plot(plot)
    return graph
Esempio n. 6
0
    def __init__(self, **kwargs):
        super(MyGraphs, self).__init__(**kwargs)
        self.cols = 1

        # Graphs init
        self.graph = graph = Graph(xlabel='čas',
                                   ylabel='C',
                                   x_ticks_minor=1,
                                   x_ticks_major=5,
                                   y_ticks_major=10,
                                   y_grid_label=True,
                                   x_grid_label=True,
                                   padding=5,
                                   x_grid=True,
                                   y_grid=True,
                                   xmin=-0,
                                   xmax=10,
                                   ymin=-1,
                                   ymax=1)

        self.backButton = Button(text="Back", size_hint=(1, .1))
        self.backButton.bind(on_touch_down=self.backButtonPressed)

        self.mainLayout = GridLayout(rows=2)
        self.mainLayout.add_widget(graph)
        self.mainLayout.add_widget(self.backButton)
        self.add_widget(self.mainLayout)
Esempio n. 7
0
    def __init__(self, ticker):
        self.CurrentPrice = 0
        self.dt = 0
        self.ticker = ticker
        self.cryptos = []
        self.yticks = 100
        for dicto in json.loads(
                requests.get(
                    'https://finnhub.io/api/v1/crypto/symbol?exchange=binance&token=bvtss4748v6pijnevmqg'
                ).text):

            self.cryptos.append(dicto['symbol'])

        self.xticks = 10
        self.xmax = 50
        self.chart = Graph(
            xlabel='Time',
            ylabel='Price',
            x_ticks_minor=0,
            x_ticks_major=self.xticks,
            y_ticks_major=self.yticks,
            y_grid_label=True,
            x_grid_label=True,
            padding=5,
            x_grid=True,
            y_grid=True,
            xmin=0,
            xmax=self.xmax,
            ymin=0,
        )

        self.plot = SmoothLinePlot(color=[1, 1, 1, 1])
        self.chart.add_plot(self.plot)
Esempio n. 8
0
    def __init__(self, information=None):
        super(Logic, self).__init__()

        if information is None:
            information = dict()

        self.information = information

        self.mi = dict()
        self.nmi = dict()
        self.tmi = dict()
        self.twomi = dict()

        self.graph = Graph(xlabel='X',
                           ylabel='Y',
                           x_ticks_minor=.25,
                           x_ticks_major=1,
                           y_ticks_minor=1,
                           y_ticks_major=1,
                           y_grid_label=True,
                           x_grid_label=True,
                           padding=5,
                           x_grid=True,
                           y_grid=True,
                           xmin=-1,
                           xmax=24,
                           ymin=-1,
                           ymax=1)
        self.red_plot = MeshLinePlot(color=[1, 0, 0, 1])
        self.gre_plot = MeshLinePlot(color=[0, 1, 0, 1])
        self.blu_plot = MeshLinePlot(color=[0, 0, 1, 1])
        self.yel_plot = MeshLinePlot(color=[1, 1, 0, 1])

        self.add_widget(widget=self.graph)
def make_plot(ratings_list, plot_dates, plot_tickers, plot_colors):
    # Prepare the data
    x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

    # make the graph
    graph = Graph(ylabel='Ratings',
                  x_ticks_major=1,
                  y_ticks_minor=1,
                  y_ticks_major=1,
                  y_grid_label=True,
                  x_grid_label=False,
                  padding=5,
                  x_grid=True,
                  y_grid=True,
                  xmin=0,
                  xmax=10,
                  ymin=0,
                  ymax=10)

    if (len(plot_tickers) > 0):
        i = 0
        while (i < len(plot_tickers)):
            plot = MeshLinePlot(color=plot_colors[i])
            plot.points = [(i, j) for i, j in zip(x, ratings_list[i])]

            graph.add_plot(plot)
            i += 1

    return graph
Esempio n. 10
0
    def update(self):
        self.remove_widget(self.graph)
        self.graph = Graph(xlabel="x",
                           ylabel="y",
                           x_ticks_major=self.x_range / 2,
                           y_ticks_major=self.y_range / 2,
                           y_grid_label=True,
                           x_grid_label=True,
                           x_grid=True,
                           y_grid=True,
                           xmin=-self.x_range,
                           xmax=self.x_range,
                           ymin=-self.y_range,
                           ymax=self.y_range,
                           draw_border=False)
        self.plot = MeshLinePlot(color=[1, 1, 1, 1])
        x = -self.x_range
        self.plot.points = []
        while x < self.x_range:
            try:
                self.plot.points.append((x, sin(x)))
            except ZeroDivisionError:
                pass

            x += self.x_range / 100
        self.add_widget(self.graph)

        self.graph.add_plot(self.plot)
Esempio n. 11
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 = []
Esempio n. 12
0
 def tabProbabilityTesting(self):
     '''
     tab containing plot of probability distributions from various user-specificed pools of dice
     '''
     self.plotColorMap = [
         [1,0,0,1],
         [0,1,0,1],
         [0,0,1,1],
         [1,1,0,1],
         [1,0,1,1],
         [0,1,1,1],
         [1,1,1,1],
         [0.75,0.75,0.75,1]]
     tabProb = TabbedPanelItem(text = 'Prob. Plots')
     self.statsMainLayout = BoxLayout(orientation = 'vertical')
     self.entryLayout =  BoxLayout(orientation = 'vertical',size_hint = (1,0.45))
     buttonLayout = BoxLayout(size_hint = (1,0.05))
     self.graphLayout = BoxLayout(size_hint = (1,0.5))
     self.graph = Graph(xlabel='Value', ylabel='Counts', 
         x_ticks_minor=1,x_ticks_major=2, y_ticks_minor = 100, y_ticks_major=500,
         y_grid_label=True, x_grid_label=True, padding=5,
         x_grid=True, y_grid=True, xmin=-0, xmax=15, ymin=0,ymax = 5000)
     self.graphLayout.add_widget(self.graph)
     self.plotList = []
     self.statsMainLayout.add_widget(self.entryLayout)
     self.statsMainLayout.add_widget(buttonLayout)
     self.statsMainLayout.add_widget(self.graphLayout)
     self.testList = []
     self.appendNewTest(self.entryLayout,readOnly = True) 
     self.testList.append(self.appendNewTest(self.entryLayout)) 
     buttonList = [['Add New Test','Plot Results','Reset']]
     buttonFunctionList = [[self.fireNewTestButton,self.firePlotButton,self.fireResetTestsButton]]
     self.addButtons(buttonList,buttonFunctionList,buttonLayout)
     tabProb.add_widget(self.statsMainLayout)
     return tabProb    
Esempio n. 13
0
    def __init__(self, **kwargs):
        super(GraphPlot, self).__init__(**kwargs)
        self.y_range = 10
        self.x_range = 10
        self.range_multiplier = [2, 2.5, 2]
        self.graph = Graph(xlabel="x",
                           ylabel="y",
                           x_ticks_major=self.x_range / 2,
                           y_ticks_major=self.y_range / 2,
                           y_grid_label=True,
                           x_grid_label=True,
                           x_grid=True,
                           y_grid=True,
                           xmin=-self.x_range,
                           xmax=self.x_range,
                           ymin=-self.y_range,
                           ymax=self.y_range,
                           draw_border=False)
        # graph.size = (1200, 400)
        # self.graph.pos = self.center

        self.plot = MeshLinePlot(color=[1, 1, 1, 1])
        x = -self.x_range
        self.plot.points = []
        while x < self.x_range:
            try:
                self.plot.points.append((x, sin(x)))
            except ZeroDivisionError:
                pass

            x += self.x_range / 100
        self.add_widget(self.graph)

        self.graph.add_plot(self.plot)
Esempio n. 14
0
 def setupGui(self):
     self.sogG = Graph(
         ymax=1.0,
         ymin=-1.0,
     )
     self.sogP = MeshLinePlot(color=[1, 1, 0, 1])
     self.sogG.add_plot(self.sogP)
     self.gui.rl.ids.flRace.add_widget(self.sogG)
Esempio n. 15
0
 def build(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, 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
Esempio n. 16
0
    def __init__(self, game, screen, **kwargs):
        super(StateInfoBar, self).__init__(game, screen, **kwargs)

        # Right graph
        self.graph1 = graph1 = Graph(xlabel='Game',
                                     ylabel='Reward',
                                     x_ticks_major=self.DEFAULT_X_TICKS_MAJOR,
                                     y_ticks_major=self.DEFAULT_Y_TICKS_MAJOR,
                                     y_grid_label=True,
                                     x_grid_label=True,
                                     padding=5,
                                     x_grid=True,
                                     y_grid=True,
                                     xmin=self.DEFAULT_XMIN,
                                     xmax=self.DEFAULT_XMAX,
                                     ymin=self.DEFAULT_YMIN,
                                     ymax=self.DEFAULT_YMAX)

        self.plot1 = plot1 = MeshLinePlot(color=[1, 0, 0, 1])
        plot1.points = []
        graph1.add_plot(plot1)

        self.ids["graph1"].add_widget(graph1)

        # Left graph
        self.graph2 = graph2 = Graph(xlabel='Generation',
                                     ylabel='MaxFitness',
                                     x_ticks_major=self.DEFAULT_X_TICKS_MAJOR,
                                     y_ticks_major=self.DEFAULT_Y_TICKS_MAJOR,
                                     y_grid_label=True,
                                     x_grid_label=True,
                                     padding=5,
                                     x_grid=True,
                                     y_grid=True,
                                     xmin=self.DEFAULT_XMIN,
                                     xmax=self.DEFAULT_XMAX,
                                     ymin=self.DEFAULT_YMIN,
                                     ymax=self.DEFAULT_YMAX)

        self.plot2 = plot2 = MeshLinePlot(color=[0, 1, 0, 1])
        plot2.points = []
        graph2.add_plot(plot2)

        self.ids["graph2"].add_widget(graph2)
Esempio n. 17
0
    def __init__(self, aircraft_config, **kwargs):
        super(AircraftLoadLayout, self).__init__(**kwargs)
        self.cols = 1
        self.cfg = load_aircraft_config(aircraft_config)
        self.loads = create_loads_list(self.cfg)

        acft = self.cfg.aircraft
        self.lbl_info = Label(text="%s (%s)" % (acft.designation, acft.immat))
        self.add_widget(self.lbl_info)

        self.sliders = SlidersLayout(self.cfg, self.loads)
        self.add_widget(self.sliders)

        self.lbl_center_gravity = Label(text="")
        self.add_widget(self.lbl_center_gravity)

        self.graph = Graph(
            xlabel="X",
            ylabel="mass",
            # x_ticks_minor=0.05, x_ticks_major=0.5,
            # y_ticks_major=100, # y_ticks_minor=20,
            y_grid_label=True,
            x_grid_label=True,
            padding=5,
            x_grid=True,
            y_grid=True,
            xmin=0.7,
            xmax=1.1,
            ymin=0,
            ymax=1000,
        )
        self.mesh_line_plot = MeshLinePlot(color=[0, 0, 1, 1])
        self.graph.add_plot(self.mesh_line_plot)

        self.add_widget(self.graph)

        self.btn_toggle = ToggleButton(
            text="lever arm / moment",
            group="xaxis",
        )
        self.btn_toggle.bind(on_press=self.on_touch_move)
        self.add_widget(self.btn_toggle)

        # point = Point(0.8, 400)
        # plot = ScatterPlot(color=(1,0,0,1), pointsize=5)
        self.scatter_plot = ScatterPlot(color=[1, 0, 0, 1], point_size=5)
        # plot.points.append((0.8, 400))
        self.graph.add_plot(self.scatter_plot)

        self.update_label_plot()
Esempio n. 18
0
    def rainGraph(self):
        rainY = []
        for i in range(len(self.fileData) - 19, len(self.fileData)):
            rainY.append(str(math.floor((float(self.fileData[i][8])))))
        plot = None
        graph = Graph(size_hint = (0.5,0.8), pos_hint = {'x': .24, 'y': 0}, ylabel='Rain Events', xlabel='Time', x_ticks_major=1, y_ticks_minor=1,
                      y_ticks_major=1,
                      y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True,
                      xmin=0, xmax=20, ymin=0, ymax=50, background_color = [1,1,1,.2])

        plot = MeshLinePlot(color=[.5, 0, .5, 1])
        plot.points = [(int(i), int(rainY[i])) for i in range(0, 19)]
        graph.add_plot(plot)

        return graph
Esempio n. 19
0
    def humidGraph(self):
        humidY = []

        for i in range(len(self.fileData) - 19, len(self.fileData)):
            humidY.append(str(math.floor((float(self.fileData[i][4])))))

        humidityPlot = None
        humidityGraph = Graph(size_hint = (0.5,0.8), pos_hint = {'x': .24, 'y': 0}, ylabel='% Humidity', xlabel='Time', x_ticks_major=1, y_ticks_minor=1, y_ticks_major=1,
                      y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True,
                      xmin=0, xmax=20, ymin=0, ymax=100, background_color = [1,1,1,.2])

        humidityPlot = MeshLinePlot(color=[.5,0 ,.5, 1])
        humidityPlot.points = [(int(i), int(humidY[i])) for i in range(0, 19)]
        humidityGraph.add_plot(humidityPlot)

        return humidityGraph
Esempio n. 20
0
    def tempGraph(self):

        tempY =[]

        for i in range(len(self.fileData) - 19, len(self.fileData)):
            tempY.append(str(math.floor((float(self.fileData[i][6])))))

        plot = None
        graph = Graph(size_hint = (.5,.8), ylabel='Outside Temperature (C)', xlabel = 'Time', x_ticks_major = 1, y_ticks_minor = 1, y_ticks_major = 1,
                  y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True,
                  xmin=0, xmax=20, ymin=-10, ymax=50, pos_hint = {'x': .24, 'y': .2}, background_color = [1,1,1,.2])

        plot = MeshLinePlot(color = [1,1,1,1])

        plot.points = [(int(i), int(tempY[i])) for i in range(0, 19)]
        graph.add_plot(plot)
        return graph
Esempio n. 21
0
 def default_graph_waveform(self):
     self.graph = Graph(xlabel='t (s) or steps',
                        ylabel='BP (mmHg)',
                        x_ticks_minor=5,
                        x_ticks_major=1.0,
                        y_ticks_major=50,
                        y_grid_label=True,
                        x_grid_label=True,
                        padding=5,
                        x_grid=True,
                        y_grid=True,
                        xmin=-0,
                        xmax=10.0,
                        ymin=0,
                        ymax=240)
     self.plot = MeshLinePlot(color=[1, 1, 1, 1])
     self.plot.points = [(x * 0.02, 5) for x in range(0, 501)]
     self.graph.add_plot(self.plot)
Esempio n. 22
0
    def create_graph(self):
        """Création du graph seul et pas d'ajout au widget"""

        print("Appel de la création du graph ..")
        self.unit_x = "minutes"

        # Paramètres du graph en x
        self.xmin = 0
        self.xmax = 1000
        self.x_ticks_major = 3600
        self.x_ticks_minor = 600

        # Paramètres du graph en y
        self.ymin = 0
        self.ymax = self.y_major
        self.ylabel = self.unit_y
        self.y_ticks_major = self.y_major / 10
        self.y_ticks_minor = 0  #5

        # Je crée ou recrée
        self.graph = Graph(background_color=(0.8, 0.8, 0.8, 1),
                           border_color=(0, 0.1, 0.1, 1),
                           xlabel=self.xlabel,
                           ylabel=self.ylabel,
                           x_ticks_minor=self.x_ticks_minor,
                           x_ticks_major=self.x_ticks_major,
                           y_ticks_major=self.y_ticks_major,
                           x_grid_label=True,
                           y_grid_label=True,
                           padding=10,
                           view_pos=(10, -10),
                           x_grid=True,
                           y_grid=True,
                           xmin=self.xmin,
                           xmax=self.xmax,
                           ymin=self.ymin,
                           ymax=self.ymax,
                           tick_color=(1, 0, 1, 1),
                           label_options={'color': (0.2, 0.2, 0.2, 1)})

        self.graph.add_plot(self.curve_plot)
        self.ids.graph_id.add_widget(self.graph)
Esempio n. 23
0
def all_graph(Shear_list, length, position, label):
    datapoints = np.arange(0, length, 0.01)
    point_data_list = []
    multiplier = 1
    if label == "Bending moment (kNm)" or label == "Deflection (1/EI)" or 'Axial Stress (kN)':
        multiplier = -1
    ymax = 0
    ymin = 0
    min_y = 0
    max_y = 0
    for i in range(len(datapoints)):
        point_data = 0
        for all in Shear_list:
            point_data += all.calculate(datapoints[i])*multiplier
        if point_data + abs(point_data / 5) > ymax:
            ymax = point_data + abs(point_data / 5)
        elif ymin > point_data - abs(point_data / 5):
            ymin = point_data - abs(point_data / 5)
        point_data_list.append((datapoints[i], point_data))
        if i == 0:
            max_y = point_data
            min_y = point_data
        else:
            max_y = max(point_data, max_y)
            min_y = min(point_data, min_y)
    ymax = int(round(ymax, 0))
    ymin = int(round(ymin, 0))
    max_y = round(max_y, 3)
    min_y = round(min_y, 3)
    if ymax == 0:
        ymax = 1
    if ymin == 0:
        ymin = -1
    graph = Graph(pos_hint=position, size_hint=(0.7, 0.9), xlabel='Position', ylabel=label, x_ticks_minor=5,
                  x_ticks_major=length / 10, x_grid_label=True, y_grid_label=True, y_ticks_major=(ymax-ymin)/5,
                  y_ticks_minor=5, padding=5, x_grid=True, y_grid=True, xmax=length, xmin=0, ymin=ymin, ymax=ymax)
    plot = MeshLinePlot()
    plot.points = point_data_list
    graph.add_plot(plot)
    return graph, [min_y, max_y]
Esempio n. 24
0
    def __init__(self, **kwargs):
        super().__init__()
        self.graph = Graph(x_ticks_minor=4,
                           x_ticks_major=16,
                           y_grid_label=True,
                           x_grid_label=True,
                           padding=5,
                           x_grid=True,
                           y_grid=True,
                           xmin=-0,
                           xmax=SAMPLES,
                           ymin=0,
                           **kwargs)
        self.plot = MeshLinePlot(color=[1, 1, 0, 1])
        self.plot.points = [(x, 0) for x in range(0, SAMPLES + 1)]
        self.graph.add_plot(self.plot)
        self.total_plot = MeshLinePlot(color=[0, 1, 1, 1])
        self.total_plot.points = [(x, 0) for x in range(0, SAMPLES + 1)]
        self.graph.add_plot(self.total_plot)

        self.values = collections.defaultdict(
            lambda: [0 for x in range(0, SAMPLES + 1)])
Esempio n. 25
0
    def __init__(self, **kwargs):
        super(StockDetailScreen, self).__init__(**kwargs)

        self.layout = CustomLayout()
        back_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1))
        self.layout.add_item(CustomButton(back_img, on_release_func=lambda: back(self.manager), alignment='left'))

        self.stock_name = lm.createLabel(bold= False, rel_size= (1, .1), text_rel_size = (.95, .1), halign='center', valign='middle')
        self.layout.add_item(self.stock_name)

        self.layout.add_widget(Button(text="TRADE", bold=True, font_size=40,
                                        background_color=DARK_GREEN, on_release=self.trade),                                        
                                        rel_size=(.8, .1))

        self.current_price = lm.createLabel(font_size= 50, rel_size= (1, .1))

        self.layout.add_item(self.current_price)
        self.center_image = lm.createImage(source='images/up_arrow.png', rel_size=lm.rel_square(rel_width=.5))
        self.layout.add_item(self.center_image)

        self.stock_symbol = lm.createLabel(font_size= 50, rel_size= (1, .1))
        self.layout.add_item(self.stock_symbol)

        self.num_shares = lm.createLabel(font_size= 28, rel_size= (1, .1))
        self.layout.add_item(self.num_shares)

        self.layout.add_item(lm.createLabel(text = 'Past Week Performace', font_size= 28, rel_size= (1, .1)))

        # graph
        self.graph = Graph(x_ticks_major=1, tick_color = (0,0,0,.5), xlabel='Days',
              y_grid_label=True, x_grid_label=True, precision='%.2f', padding=5,
              x_grid=True, y_grid=True, xmin=-5, xmax=-1, ymin=0, ymax=100,
              border_color = (0,0,0,0), label_options = {'color': (0,0,0,1)})        

        self.plot = [(i-7, .3*i*100) for i in range(7)]

        self.layout.add_widget(self.graph, rel_size=(.90, .3))

        self.add_widget(self.layout.create())
Esempio n. 26
0
class MainWindow(Screen):
    graph_P = ObjectProperty(Graph())
    graph_F = ObjectProperty(Graph())
    graph_V = ObjectProperty(Graph())

    pip_string = StringProperty("--")
    peep_string = StringProperty("--")
    ti_string = StringProperty("--")
    fio2_string = StringProperty("--")
    ie_string = StringProperty("--")
    bpm_string = StringProperty("--")
    pif_string = StringProperty("--")
    vti_string = StringProperty("--")

    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)

    def update(self, *args):
        global count, record_time, EnableRecord
        # if offset < 80 and count == 9.5:
        #     offset += 5

        # self.graph_F.ymax = offset+3
        # self.graph_F.ymin = -offset+2

        if EnableRecord or EnableShow or EnableGraph:
            try:
                self.parameters.pressure = 105.0 / 4.0 * (
                    ADC.ADS1256_GetChannalValue(1) * 5.0 / 0x7fffff -
                    0.5) - 5.0
                self.parameters.flow = (-1) * (ADC.ADS1256_GetChannalValue(2) *
                                               5.0 / 0x7fffff - 2.5) * 125.0
                self.parameters.oxygen = (
                    39) * (ADC.ADS1256_GetChannalValue(0) * 5.0 / 0x7fffff -
                           3.0) + 100.0

            except:
                pass

        if EnableRecord:
            self.ids['grabar'].background_color = (0.0, 0.7, 0.0, 1.0)
            self.ids['grabar'].text = str(record_time -
                                          datetime.datetime.now())[2:7]
            if (record_time - datetime.datetime.now()) < datetime.timedelta(0):
                EnableRecord = False

            recordCSV(CSV_file_name, self.parameters.pressure,
                      self.parameters.flow, self.parameters.oxygen)

        else:
            self.ids['grabar'].text = "Grabación"
            self.ids['grabar'].background_color = (0.15, 0.15, 0.15, 1.0)

        if EnableShow:
            self.parameters.calculateALL()
            try:
                self.pip_string = str(round(self.parameters.pip['current'], 1))
                self.peep_string = str(
                    round(self.parameters.peep['current'], 1))
                self.ti_string = str(round(self.parameters.ti['current'], 2))
                self.fio2_string = str(round(self.parameters.oxygen, 1))
                self.ie_string = str(round(self.parameters.ie['current'], 1))
                self.bpm_string = str(round(self.parameters.bpm['current'], 1))
                self.pif_string = str(round(self.parameters.pif['current'], 1))
                self.vti_string = str(int(self.parameters.vti['current']))
            except:
                pass
        else:
            self.pip_string = "--"
            self.peep_string = "--"
            self.ti_string = "--"
            self.fio2_string = "--"
            self.ie_string = "--"
            self.bpm_string = "--"
            self.pif_string = "--"
            self.vti_string = "--"

        if EnableGraph:
            if count >= 10:
                self.plot_p.points.clear()
                self.plot_f.points.clear()
                self.plot_v.points.clear()
                count = 0

            self.plot_p.points.append((count, self.parameters.pressure))
            self.graph_P.add_plot(self.plot_p)

            self.plot_f.points.append((count, self.parameters.flow))
            self.graph_F.add_plot(self.plot_f)

            self.plot_v.points.append((count, self.parameters.volume))
            self.graph_V.add_plot(self.plot_v)

            count += 0.025

    def graphButton(self):
        global EnableGraph, count
        if self.ids['graficar'].background_color == [0.0, 0.7, 0.0, 1.0]:
            self.ids['graficar'].background_color = (0.15, 0.15, 0.15, 1.0)
            EnableGraph = False
            count = 0
            self.plot_p.points.clear()
            self.plot_f.points.clear()
            self.plot_v.points.clear()
            self.graph_P.add_plot(self.plot_p)
            self.graph_F.add_plot(self.plot_f)
            self.graph_V.add_plot(self.plot_v)
            return

        elif self.ids['graficar'].background_color == [0.15, 0.15, 0.15, 1]:
            self.ids['graficar'].background_color = (0.0, 0.7, 0.0, 1.0)
            EnableGraph = True
            return

    def showButton(self):
        global EnableShow
        if self.ids['mostrar'].background_color == [0.0, 0.7, 0.0, 1.0]:
            self.ids['mostrar'].background_color = (0.15, 0.15, 0.15, 1.0)
            EnableShow = False
            return
        elif self.ids['mostrar'].background_color == [0.15, 0.15, 0.15, 1]:
            self.ids['mostrar'].background_color = (0.0, 0.7, 0.0, 1.0)
            EnableShow = True
            return

    def recordButton(self):
        global EnableRecord
        if self.ids['grabar'].background_color == [0.0, 0.7, 0.0, 1.0]:
            self.ids['grabar'].background_color = (0.15, 0.15, 0.15, 1.0)
            EnableRecord = False
            print("hola")
            return
        elif self.ids['grabar'].background_color == [0.15, 0.15, 0.15, 1]:
            App.get_running_app().root.current = "record"
            self.manager.transition.direction = "down"
            return

    def infoButton(self):
        if self.ids['info'].background_color == [0.0, 0.7, 0.0, 1.0]:
            self.ids['info'].background_color = (0.15, 0.15, 0.15, 1.0)
            return
        elif self.ids['info'].background_color == [0.15, 0.15, 0.15, 1]:
            self.ids['info'].background_color = (0.0, 0.7, 0.0, 1.0)
            return

    def exitButton(self):
        exit()
Esempio n. 27
0
from math import sin
from kivy_garden.graph import Graph, MeshLinePlot

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)
Esempio n. 28
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()
Esempio n. 29
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, ))
Esempio n. 30
0
    def create_graph(self):
        """Création du graph seul et pas d'application au widget"""

        print("Appel de la création du graph ..")

        if self.xlabel == "Unité en Minutes: 0 = valeur actuelle":
            self.duration = "jour"
            self.unit_x = "minutes"
        else:
            self.duration = "semaine"
            self.unit_x = "heures"

        # Paramètres du graph en x
        # Jour
        self.xmin = 0
        if self.duration == "jour":
            # un jour = 24*60 = 1440 mn
            # 1440/6 = 240 valeurs dans l'histo
            # self.xmax = 1440 mn
            self.xmax = len(self.histo) * 6
            # 1440/4 = 360
            self.x_ticks_major = 360
            self.x_ticks_minor = 6 # divise en 6 les 360

        # Semaine
        else:
            self.xmax = len(self.histo)
            self.x_ticks_major = 24
            self.x_ticks_minor = 6  # divise en 6 les 24

        if "PM 10" in self.titre or "PM 2.5" in self.titre:
            self.xlabel += "\nEn rouge: valeur réglementaire maxi"

        # Paramètres du graph en y
        self.ymin = 0
        self.ymax = self.y_major
        self.ylabel = self.unit_y
        self.y_ticks_major = self.y_major/10
        self.y_ticks_minor = 0  #5

        # Je crée ou recrée
        self.graph = Graph( background_color=(0.8, 0.8, 0.8, 1),
                            border_color=(0, 0.1, 0.1, 1),
                            xlabel=self.xlabel,
                            ylabel=self.ylabel,
                            x_ticks_minor=self.x_ticks_minor,
                            x_ticks_major=self.x_ticks_major,
                            #y_ticks_minor=self.y_ticks_minor,
                            y_ticks_major=self.y_ticks_major,
                            x_grid_label=True,
                            y_grid_label=True,
                            padding=5,
                            x_grid=True,
                            y_grid=True,
                            xmin=self.xmin,
                            xmax=self.xmax,
                            ymin=self.ymin,
                            ymax=self.ymax,
                            tick_color=(1, 0, 1, 1),
                            label_options={'color': (0.2, 0.2, 0.2, 1)})

        self.graph.add_plot(self.curve_plot)
        self.graph.add_plot(self.line_plot)
        self.ids.graph_id.add_widget(self.graph)