예제 #1
0
def show_2d_plot():
    global data
    global buffer
    global dpg_ids
    global initialised_plots

    if buffer == -1:
        length_to_show = data.shape[-1]
    else:
        length_to_show = buffer

    assert len(
        data.shape) > 1, ('The Data provided to a Multi Pane Plot must be 2D')
    number_of_lines = data.shape[0]

    if not initialised_plots:
        for n in np.arange(number_of_lines):
            dpg_ids["Plot {}".format(n)] = \
                dpg.add_plot(label="Plot {}".format(n), height=int(800 / data.shape[0]), width=1030, show=True,
                             parent=dpg_ids['Visualisation'])
            dpg_ids['x_axis {}'.format(n)] = \
                dpg.add_plot_axis(dpg.mvXAxis, label='Data index', parent=dpg_ids["Plot {}".format(n)])
            dpg_ids['y_axis {}'.format(n)] = \
                dpg.add_plot_axis(dpg.mvYAxis, label='Data[{}]'.format(n), parent=dpg_ids["Plot {}".format(n)])
            dpg_ids['Plot line {}'.format(n)] = dpg.add_line_series(
                np.arange(length_to_show),
                data[n:length_to_show],
                parent=dpg_ids['y_axis {}'.format(n)])
        initialised_plots = True

    for n in np.arange(number_of_lines):
        dpg.set_value(dpg_ids['Plot line {}'.format(n)],
                      [np.arange(length_to_show), data[n, :length_to_show]])
예제 #2
0
def start_dpg():
    """
    The outside loop runs forever and blocks when the dpg.start_dearpygui() is called.
    When the plot_callback() calls dpg.stop_dearpygui() then it continues running forever until the
    visualisation_on turns on at which point the start_dearpygui is called again and this blocks
    :return: Nothing
    """
    global visualisation_type
    global visualiser_showing
    global is_dearpygui_running
    global dpg_ids
    global initialised_plots

    is_dearpygui_running = True
    initialised_plots = False

    dpg.create_context()
    dpg.create_viewport(title='Visualising', width=330, height=280)

    with dpg.window(label="Visualisation",
                    show=True) as dpg_ids['Visualisation']:
        if visualisation_type == 'Value':
            dpg_ids['Text'] = dpg.add_text(default_value='__start__',
                                           label='Value')
            dpg.set_item_width(dpg_ids['Visualisation'], 300)
            dpg.set_item_height(dpg_ids['Visualisation'], 250)
        elif visualisation_type == 'Single Pane Plot':
            dpg.set_viewport_width(1050)
            dpg.set_viewport_height(770)
            dpg.set_item_width(dpg_ids['Visualisation'], 1050)
            dpg.set_item_height(dpg_ids['Visualisation'], 770)
            with dpg.plot(label="Plot",
                          height=700,
                          width=1000,
                          show=True,
                          pan_button=True,
                          fit_button=True) as dpg_ids['Plot 0']:
                dpg_ids['x_axis'] = dpg.add_plot_axis(dpg.mvXAxis,
                                                      label="Data index")
                dpg_ids['y_axis'] = dpg.add_plot_axis(dpg.mvYAxis,
                                                      label="Data")

        elif visualisation_type == 'Multi Pane Plot':
            dpg.set_viewport_width(1050)
            dpg.set_viewport_height(850)
            dpg.set_item_width(dpg_ids['Visualisation'], 1050)
            dpg.set_item_height(dpg_ids['Visualisation'], 820)

    dpg.set_viewport_resize_callback(on_resize_viewport)
    dpg.setup_dearpygui()
    dpg.show_viewport()

    visualiser_showing = True
    if data is not None:
        update_dpg_gui()

    dpg.start_dearpygui()
    dpg.destroy_context()
예제 #3
0
파일: main.py 프로젝트: filipecn/maldives
def _volume_plot_drop(sender, app_data, user_data):
    ta = prices[window_data.selected_ticker]['ta']
    dates = (ta.data['date'].astype('int64') // 1e9).to_list()
    if app_data[0] == 'RSI':
        if window_data.volume_unit_yaxis == 0:
            window_data.volume_unit_yaxis = dpg.add_plot_axis(dpg.mvYAxis, label="RSI",
                                                              parent=window_data.volume_plot)
        indicators.add_rsi_series(dpg.get_value(app_data[1]), dpg.get_value(app_data[2]), dates, ta,
                                  window_data.volume_unit_yaxis)
        dpg.set_axis_limits(window_data.volume_unit_yaxis, 0, 100)
예제 #4
0
              'r_wrist_roll_joint': []}
last_command  = {}


if __name__ == '__main__':
    with dpg.window(label="Test"):

        for name, deltas in all_deltas.items():
            # create plot
            with dpg.plot(label=f"{name} deltas", height=200, width=900):

                # optionally create legend
                dpg.add_plot_legend()

                # REQUIRED: create x and y axes
                dpg.add_plot_axis(dpg.mvXAxis, label="x")
                dpg.set_axis_limits(dpg.last_item(), 0, len(x_coords))
                dpg.add_plot_axis(dpg.mvYAxis, label="y")
                dpg.set_axis_limits(dpg.last_item(), -1, 1)

                # series belong to a y axis
                dpg.add_line_series(x_coords[:len(deltas)], deltas, label=f'{name}', parent=dpg.last_item(), id=f'{name}_deltas')


    log_lock = RLock()

    def cb_state(state_msg):
        with log_lock:
            for name, velocity in zip(state_msg.name, state_msg.velocity):
                if name in last_command and name in all_deltas:
                    delta = last_command[name] - velocity
예제 #5
0
파일: main.py 프로젝트: filipecn/maldives
                #     dpg.add_date_picker(level=dpg.mvDatePickerLevel_Day,
                #                         default_value={'month_day': 8, 'year': 93, 'month': 5},
                #                         callback=)
                #     dpg.add_button(label="OK", width=75, user_data=modal_id, callback=_period)
                dpg.add_radio_button(("1y", '6m', '1m', '1w', '1d'), callback=_period, horizontal=True)
                dpg.add_same_line()
                dpg.add_text(' on intervals of: ')
                dpg.add_same_line()
                dpg.add_radio_button(("15m", '30m', '1h', '1d'), callback=_interval, horizontal=True)

                # with dpg.menu(label='date'):
                #     dpg.add_time_picker(default_value={'hour': 14, 'min': 32, 'sec': 23})
                with dpg.plot(label="Candle Series", height=400, width=-1, drop_callback=_candle_plot_drop,
                              payload_type='candle_plot', no_title=True, anti_aliased=True) as window_data.candle_plot:
                    dpg.add_plot_legend()
                    window_data.candle_xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="", time=True)
                    window_data.candle_yaxis = dpg.add_plot_axis(dpg.mvYAxis, label="BRL")
                with dpg.plot(label='volume_plot', height=300, width=-1, no_title=True, payload_type='volume_plot',
                              drop_callback=_volume_plot_drop, callback=_volume_plot_drop) as window_data.volume_plot:
                    dpg.add_plot_legend()
                    window_data.volume_xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="", time=True)
                    window_data.volume_yaxis = dpg.add_plot_axis(dpg.mvYAxis, label="VOL")

                _node_editor()

            with dpg.child(label='column_2', width=200, height=500):
                left_parent = dpg.last_item()
        # footer
        with dpg.child(label='footer', height=200):
            logger.init(dpg.last_item())
예제 #6
0
    def setUp(self):

        dpg.create_context()

        with dpg.window() as self.window_id:

            def testy(sender, app, user):
                print(f"Sender: {dpg.get_item_type(sender)} {sender}, App Data: {app}, User Data:{user}")

            # Menus
            with dpg.menu_bar() as menu_bar:
                dpg.add_menu_item(label="menu item", payload_type="str", drop_callback=testy)
                with dpg.menu(label="menu", payload_type="str", drop_callback=testy):
                    dpg.add_menu_item(label="menu item")


            # basic
            with dpg.collapsing_header(label="basic") as basic:
                dpg.add_image(dpg.mvFontAtlas)
                dpg.add_image_button(dpg.mvFontAtlas)
                dpg.add_text("this is a text widget")
                dpg.add_checkbox(label="checkbox")
                dpg.add_button(label="button")
                dpg.add_input_float(label="input float")
                dpg.add_input_floatx(label="input floatx")
                dpg.add_drag_int(label="drag int")
                dpg.add_drag_intx(label="drag intx")
                dpg.add_input_text(label="input text")
                dpg.add_slider_float(label="slider float")
                dpg.add_slider_floatx(label="slider floatx")
                dpg.add_listbox(label="listbox")
                dpg.add_selectable(label="selectable")
                dpg.add_radio_button(["item 1", "item 2"],label="radio button")

            # color
            with dpg.collapsing_header(label="color") as color:
                with dpg.group() as color:
                    dpg.add_color_button([255,0,0,255])
                    dpg.add_color_edit([255,0,0,255])
                    dpg.add_colormap_button(label="Colormap Button 1")
                    dpg.add_color_picker((255, 0, 255, 255), label="Color Picker", width=200)
                dpg.add_colormap_slider(label="Colormap Slider 1", default_value=0.5, payload_type="str", drop_callback=testy)
                dpg.add_colormap_scale(label="Colormap Spectral", min_scale=-100, max_scale=150, payload_type="str", drop_callback=testy)

            # containers
            with dpg.collapsing_header(label="containers"):
                with dpg.group() as containers:
                    with dpg.collapsing_header():
                        btn = dpg.add_button()
                    with dpg.group(width=150):
                        dpg.add_button()
                    with dpg.tree_node():
                        dpg.add_button()
                with dpg.child_window(width=150, height=100, payload_type="str", drop_callback=testy):
                    pass

            # tab stuff
            with dpg.collapsing_header(label="tab bars"):
                with dpg.tab_bar():

                    with dpg.tab(label="tab", payload_type="str", drop_callback=testy):
                        pass
                    dpg.add_tab_button(label="tab button", payload_type="str", drop_callback=testy, drag_callback=testy)
                    with dpg.drag_payload(parent=dpg.last_item(), drop_data="dropped", drag_data="dragged", user_data="user data", payload_type="str"):
                        dpg.add_text(dpg.get_item_type(dpg.last_item()))
                        dpg.add_text(f"Item ID: {dpg.last_item()}")

            # custom
            with dpg.collapsing_header(label="custom"):
                with dpg.group() as custom:
                    dpg.add_date_picker()
                    dpg.add_knob_float()
                    dpg.add_3d_slider()
                    dpg.add_time_picker()
                dpg.add_loading_indicator(payload_type="str", drop_callback=testy)

            # misc
            with dpg.collapsing_header(label="misc"):
                with dpg.group() as misc:
                    dpg.add_progress_bar(label="progress bar", default_value=.5)

            # node
            with dpg.collapsing_header(label="node"):
                with dpg.node_editor() as node:
                    with dpg.node(pos=[20,20], draggable=False):
                        pass
                    with dpg.node(pos=[100,100], draggable=False):
                        pass

            # plots
            with dpg.collapsing_header(label="plot") as plot:
                with dpg.plot():
                    dpg.add_plot_legend(payload_type="str", drop_callback=testy)
                    dpg.add_plot_axis(dpg.mvXAxis, label="x", payload_type="str", drop_callback=testy)
                    with dpg.plot_axis(dpg.mvYAxis, label="y", payload_type="str", drop_callback=testy):
                        dpg.add_line_series([0,1,2,3,4,5], [0,1,2,3,4,5], label="data")


            self.test_bind_items = dpg.get_item_children(basic, slot=1) 
            self.test_bind_items += dpg.get_item_children(color, slot=1) 
            self.test_bind_items += dpg.get_item_children(containers, slot=1)
            self.test_bind_items += dpg.get_item_children(custom, slot=1)
            self.test_bind_items += dpg.get_item_children(misc, slot=1)
            self.test_bind_items += dpg.get_item_children(node, slot=1)
            self.test_bind_items += dpg.get_item_children(plot, slot=1)

        dpg.setup_dearpygui()
    Z.pop(0)

    dpg.configure_item("X_value", x = t, y = X )
    dpg.configure_item("Y_value", x = t, y = Y )
    dpg.configure_item("Z_value", x = t, y = Z )

    

with dpg.window() as main_window:
    pass

with dpg.window(id='Ploter', label="simple plot", no_resize=True, no_title_bar=True, no_move=True):
    with dpg.plot(id='Graph', label="Plot Acelerometro", height=300, width=400, anti_aliased=True):
        dpg.add_plot_legend()

        dpg.add_plot_axis(dpg.mvXAxis, label="Tempo", id='x_axis')
        dpg.set_axis_limits("x_axis", 0, 2*3.1415)

        dpg.add_plot_axis(dpg.mvYAxis, label="Valores XYZ", id="y_axis")
        #dpg.set_axis_limits('y_axis', -1.25,1.25)
        
        dpg.add_line_series([], [], label="X_value", id="X_value", parent="y_axis")
        dpg.add_line_series([], [], label="Y_value", id="Y_value", parent="y_axis")
        dpg.add_line_series([], [], label="Z_value", id="Z_value", parent="y_axis")


def resize_group( sender, data, user ):
    dpg.configure_item('Ploter', height = data[1], width = data[0] ) 
    dpg.configure_item('Graph', height = data[1]*0.9, width = data[0]*0.9, pos=[ data[0]*0.05, data[1]*0.05] ) 

예제 #8
0
    def custom(self):

        with dpg.plot(height=400, width=400, no_title=True):
            dpg.add_plot_axis(dpg.mvXAxis, label="", id=self.x_axis)
            dpg.add_plot_axis(dpg.mvYAxis, label="", id=self.y_axis)
예제 #9
0
def plot_perf(plot_axis):
    (names, series) = load_perf("game.log")

    index = 1 + 3 * len(names)
    for (name, data) in series.items():
        xs = [pair[0] for pair in data]
        ys = [pair[1] + (index / 2) for pair in data]
        dpg.add_line_series(xs, ys, label=name, parent=plot_axis) #, weight=2, fill=[255, 0, 0, 100])
        index -= 3

def plot_callback(sender, data):
    plot_perf(plot_axis)

dpg.setup_viewport()
width = dpg.get_viewport_width()
height = dpg.get_viewport_height()

with dpg.window(label="RRL Performance", width=width, height=height, no_move=True, no_collapse=True, no_title_bar=True) as window:

    dpg.add_text("Performance Plot")
    dpg.add_button(label="Reload file", callback=plot_callback)

    with dpg.plot(label="Perf", width=width - 40, height=height - 120):
        dpg.add_plot_legend()
        dpg.add_plot_axis(dpg.mvXAxis, label='x')
        plot_axis = dpg.add_plot_axis(dpg.mvYAxis, label='y')

    plot_perf(plot_axis)

dpg.start_dearpygui()