def handle_metric(self):
        value = core.get_value("metrics")
        core.clear_plot("Metrics plot")
        bar_positions = [2 * idx + 1 for idx in range(len(self.alg_result))]

        if len(self.alg_result):
            elapsed_times = [
                self.alg_result[idx]["elapsed_time"]
                for idx in range(len(self.alg_result))
            ]
            expanded_nodes = [
                algorithm["alg_result"]["expanded"]
                for algorithm in self.alg_result
            ]

            if value == 0:
                core.add_bar_series("Metrics plot", "Elapsed time",
                                    bar_positions, elapsed_times)
                core.set_plot_ylimits("Metrics plot", 0,
                                      max(elapsed_times) * 1.2)
            if value == 1:
                core.add_bar_series("Metrics plot", "Expanded nodes",
                                    bar_positions, expanded_nodes)
                core.set_plot_ylimits("Metrics plot", 0,
                                      max(expanded_nodes) * 1.2)

        x_ticks = [[alg, idx]
                   for alg, idx in zip(self.selected_algorithms, bar_positions)
                   ]
        core.reset_xticks("Metrics plot")
        core.set_xticks("Metrics plot", x_ticks)
示例#2
0
文件: main.py 项目: AryanAb/StockV
def create(sender, data):
    core.set_value("company_id",
                   "{} Model Created".format(model_company.split('_')[0]))
    core.clear_plot("Pred")
    predict, original = data
    core.add_line_series("Pred",
                         "Prediction",
                         predict.index.tolist(),
                         predict[0].tolist(),
                         color=[255, 50, 50, 100])
示例#3
0
 def update_chart(self, data: List[float], labels: List[str]) -> None:
     """
     Updates data and labels and updates Pie chart
     :param data: List of floats
     :param labels: List of labels
     :return: None but updates chart
     """
     self.data = data
     self.labels = labels
     c.clear_plot(self.plot_label)
     self.chart()
示例#4
0
 def display_graph(self):
     core.clear_plot(self.plotName)
     core.add_scatter_series(self.plotName,
                             name="0",
                             x=self.dataX2,
                             y=self.dataY2,
                             update_bounds=True)
     core.add_scatter_series(self.plotName,
                             name="1",
                             x=self.dataX1,
                             y=self.dataY1,
                             update_bounds=True)
    def update_data(self):
        """
        Updates data in table and plot
        """
        dev.log_debug("Called update data")
        # Setting table data
        c.set_table_data(self._table_name, data=self.table_data)

        # Clearing plot and setting new scatter plot
        c.clear_plot(self._plot_name)
        c.add_scatter_series(
            self._plot_name,
            name="Example Scatter",
            x=self.x_values,
            y=self.y_values,
        )
        # Updating plot limits
        x_lim, y_lim = self.recalculate_plot_limits()
        c.set_plot_xlimits(self._plot_name, **x_lim)
        c.set_plot_ylimits(self._plot_name, **y_lim)
示例#6
0
文件: gui.py 项目: AryanAb/StockV
def plot_callback(sender, data):

    if data == "clear":
        selected_companies.clear()
    elif data != None:
        if data not in selected_companies:
            selected_companies.append(data)
        else:
            selected_companies.remove(data)

    core.clear_plot("Plot")
    cap_callback(None, selected_cap)

    for i in range(0, len(selected_companies)):
        company = selected_companies[i]
        stocks = pd.read_csv("dataset/" + company)

        data_x = list(range(1, len(stocks.index) + 1))
        data_y = stocks['High'].tolist()
        core.add_line_series("Plot",
                             company.split('_')[0],
                             data_x,
                             data_y,
                             color=colors[i % len(colors)])
示例#7
0
文件: gui.py 项目: AryanAb/StockV
def cap_callback(sender, data):
    global selected_cap
    selected_cap = data
    core.clear_plot("Cap")

    for i in range(0, len(selected_companies)):
        company = selected_companies[i]
        stocks = pd.read_csv("dataset/" + company, parse_dates=['Date'])
        stocks['Date'] = pd.to_datetime(stocks['Date'],
                                        unit='D',
                                        errors='coerce')

        if data == "daily":
            data_x = list(range(1, len(stocks.index) + 1))
            data_y = (stocks['High'] * stocks['Volume']).tolist()
            core.add_line_series("Cap",
                                 company.split('_')[0],
                                 data_x,
                                 data_y,
                                 color=colors[i % len(colors)])

            core.add_line_series("Cap",
                                 "large-cap", [data_x[0], data_x[-1]],
                                 [10000000000, 10000000000],
                                 weight=3,
                                 color=[255, 50, 50, 100])
            core.add_line_series("Cap",
                                 "mid-cap", [data_x[0], data_x[-1]],
                                 [2000000000, 2000000000],
                                 weight=3,
                                 color=[200, 50, 50, 100])
            core.add_line_series("Cap",
                                 "small-cap", [data_x[0], data_x[-1]],
                                 [300000000, 300000000],
                                 weight=3,
                                 color=[150, 50, 50, 100])
        elif data == "monthly":
            monthly_stocks = stocks.groupby(pd.Grouper(key="Date",
                                                       freq='1M')).mean()
            data_x = list(range(1, len(monthly_stocks.index) + 1))
            data_y = (monthly_stocks['High'] *
                      monthly_stocks['Volume']).tolist()

            core.add_line_series("Cap",
                                 company.split('_')[0],
                                 data_x,
                                 data_y,
                                 color=colors[i % len(colors)])

            core.add_line_series("Cap",
                                 "large-cap", [data_x[0], data_x[-1]],
                                 [10000000000, 10000000000],
                                 weight=3,
                                 color=[255, 50, 50, 100])
            core.add_line_series("Cap",
                                 "mid-cap", [data_x[0], data_x[-1]],
                                 [2000000000, 2000000000],
                                 weight=3,
                                 color=[200, 50, 50, 100])
            core.add_line_series("Cap",
                                 "small-cap", [data_x[0], data_x[-1]],
                                 [300000000, 300000000],
                                 weight=3,
                                 color=[150, 50, 50, 100])
        elif data == "quarterly":
            quarterly_stocks = stocks.groupby(pd.Grouper(key="Date",
                                                         freq='3M')).mean()
            data_x = list(range(1, len(quarterly_stocks.index) + 1))
            data_y = (quarterly_stocks['High'] *
                      quarterly_stocks['Volume']).tolist()

            core.add_line_series("Cap",
                                 company.split('_')[0],
                                 data_x,
                                 data_y,
                                 color=colors[i % len(colors)])

            core.add_line_series("Cap",
                                 "large-cap", [data_x[0], data_x[-1]],
                                 [10000000000, 10000000000],
                                 weight=3,
                                 color=[255, 50, 50, 100])
            core.add_line_series("Cap",
                                 "mid-cap", [data_x[0], data_x[-1]],
                                 [2000000000, 2000000000],
                                 weight=3,
                                 color=[200, 50, 50, 100])
            core.add_line_series("Cap",
                                 "small-cap", [data_x[0], data_x[-1]],
                                 [300000000, 300000000],
                                 weight=3,
                                 color=[150, 50, 50, 100])
        elif data == "yearly":
            yearly_stocks = stocks.groupby(pd.Grouper(key="Date",
                                                      freq='1Y')).mean()
            data_x = list(range(1, len(yearly_stocks.index) + 1))
            data_y = (yearly_stocks['High'] * yearly_stocks['Volume']).tolist()

            core.add_line_series("Cap",
                                 company.split('_')[0],
                                 data_x,
                                 data_y,
                                 color=colors[i % len(colors)])

            core.add_line_series("Cap",
                                 "large-cap", [data_x[0], data_x[-1]],
                                 [10000000000, 10000000000],
                                 weight=3,
                                 color=[255, 50, 50, 100])
            core.add_line_series("Cap",
                                 "mid-cap", [data_x[0], data_x[-1]],
                                 [2000000000, 2000000000],
                                 weight=3,
                                 color=[200, 50, 50, 100])
            core.add_line_series("Cap",
                                 "small-cap", [data_x[0], data_x[-1]],
                                 [300000000, 300000000],
                                 weight=3,
                                 color=[150, 50, 50, 100])
示例#8
0
 def clear(self) -> None:
     dpgcore.clear_plot(self.id)
示例#9
0
 def draw_chart(self, data, labels):
     self.data = data
     self.labels = labels
     core.clear_plot(self.plot_label)
     self.chart()