Пример #1
0
    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
    def create_chart(self, data: List[float] = None, labels: List[str] = None) -> None:
        """
        Creates task chart window using base data
        :return: None
        """
        # c.
        if data is not None:
            self.data = data
        if labels is not None:
            self.labels = labels
        c.add_plot(
            self.plot_label,
            no_mouse_pos=True,
            xaxis_no_gridlines=True,
            xaxis_no_tick_marks=True,
            xaxis_no_tick_labels=True,
            yaxis_no_gridlines=True,
            yaxis_no_tick_marks=True,
            yaxis_no_tick_labels=True,
            width=300,
            height=300,
        )
        c.add_same_line()

        c.set_plot_xlimits(self.plot_label, 0, 1)
        c.set_plot_ylimits(self.plot_label, 0, 1)
Пример #3
0
    def init_ui(self):
        """Initialize the container's UI"""
        # the monitor profile is in a tab
        with dpg_simple.tab(self._tab_id, parent=self.parent, no_tooltip=True):
            # Create 2 groups and put them on the same line
            with dpg_simple.group(self._left_panel_id, parent=self._tab_id):
                # The grid input
                dpg_core.add_input_int2(
                    self._input_id,
                    parent=self._left_panel_id,
                    callback=self.input_callback,
                    default_value=[1, 1],
                )
                # snap button
                dpg_core.add_button(self._snap_id,
                                    parent=self._left_panel_id,
                                    callback=self.snap)
                # Customize grid with the plot
                dpg_core.add_plot(
                    self._plot_id,
                    parent=self._left_panel_id,
                    height=-1,
                    xaxis_lock_min=True,
                    xaxis_lock_max=True,
                    y2axis_lock_min=True,
                    y2axis_lock_max=True,
                    yaxis_no_tick_marks=True,
                    yaxis_no_tick_labels=True,
                    xaxis_no_tick_marks=True,
                    xaxis_no_tick_labels=True,
                    xaxis_no_gridlines=True,
                    yaxis_no_gridlines=True,
                )
                # Ensure the plot's limits are the work area
                dpg_core.set_plot_xlimits(self._plot_id,
                                          xmin=self.monitor.work.left,
                                          xmax=self.monitor.work.right)
                dpg_core.set_plot_ylimits(self._plot_id,
                                          ymin=self.monitor.work.top,
                                          ymax=self.monitor.work.bottom)

            # Put the application table on the right
            dpg_core.add_same_line(parent=self._tab_id)
            with dpg_simple.group(self._right_panel_id, parent=self._tab_id):
                self._app_table = AppTable(parent=self._right_panel_id)
Пример #4
0
            def make_plot():
                date_data_since = date - datetime.timedelta(30)
                scatter_plot_weekly_data = yfs.get_data(ticker, start_date=date_data_since, interval="1d")
                indecis = [x for x in scatter_plot_weekly_data.index]
                start_date = indecis[0]
                x_axis = [(x - start_date).days for x in indecis]
                y_axis_max = [scatter_plot_weekly_data.loc[x]['high'] for x in indecis]
                y_axis_min = [scatter_plot_weekly_data.loc[x]['low'] for x in indecis]
                gg.add_plot("30 Day Price Fluctuation", height=300, scale_max=.5,
                            x_axis_name=f"Days since {start_date}", y_axis_name="Single share price")
                gg.add_scatter_series("30 Day Price Fluctuation", "Day High", x=x_axis, y=y_axis_max, size=3)
                gg.add_scatter_series("30 Day Price Fluctuation", "Day Low", x=x_axis, y=y_axis_min, marker=1, size=3)

                # Set initial plot view
                gg.set_plot_xlimits("30 Day Price Fluctuation", 0, 30)
                gg.set_plot_ylimits("30 Day Price Fluctuation", min(y_axis_min)*.97, max(y_axis_max)*1.03)
                gg.set_plot_ylimits_auto("30 Day Price Fluctuation")
                gg.set_plot_xlimits_auto("30 Day Price Fluctuation")
    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
    def generate_chart(self, data, labels):
        if data is not None:
            self.data = data
        if labels is not None:
            self.labels = labels
        core.add_plot(
            self.plot_label,
            no_mouse_pos=True,
            xaxis_no_gridlines=True,
            xaxis_no_tick_marks=True,
            xaxis_no_tick_labels=True,
            yaxis_no_gridlines=True,
            yaxis_no_tick_marks=True,
            yaxis_no_tick_labels=True,
            width=500,
            height=500,
        )

        core.set_plot_xlimits(self.plot_label, 0, 1)
        core.set_plot_ylimits(self.plot_label, 0, 1)
        self.draw_chart(data, labels)
Пример #7
0
 def set_ylimits(self, limits: Optional[PlotLimits]) -> None:
     """Set the ``(min, max)`` limits for the y-axis, or pass ``None`` to use automatic limits."""
     if limits is None:
         dpgcore.set_plot_ylimits_auto(self.id)
     else:
         dpgcore.set_plot_ylimits(self.id, *limits)