Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot layer issue #606

Open
monkeycc opened this issue Dec 25, 2024 · 0 comments
Open

Plot layer issue #606

monkeycc opened this issue Dec 25, 2024 · 0 comments

Comments

@monkeycc
Copy link

DearPyGui

In the plot, I hope the rectangle can be placed at the top

Screenshots/Video:

bandicam.2024-12-25.20-00-50-608.mp4

Minimal, Complete and Verifiable Example code:

import dearpygui.dearpygui as dpg
import numpy as np
from matplotlib import cm
import time
import cv2


dpg.create_context()

with dpg.window(label="Tutorial", width=400, height=400):
    
    
    values: np.ndarray = np.random.rand(100, 100)
            
    colmap = cm.get_cmap('viridis', 256)
    lut = (colmap.colors[...,0:4]*255).astype(np.uint8)
    rescaled = ((values.astype(float) - values.min())*255/(values.max() - values.min())).astype(np.uint8)
    result = np.ones((*rescaled.shape,4), dtype=np.uint8)
    np.take(lut, rescaled, axis=0, out=result)
    result = result.flatten()/255
    
    with dpg.group(horizontal=True):
        with dpg.texture_registry(show=False):
            dpg.add_raw_texture(width=100, height=100, default_value=np.asarray(result, dtype=np.float32), tag=f"texture_tag", format=dpg.mvFormat_Float_rgba)

        with dpg.plot(label="title", height=-1, width=-1, crosshairs=True, anti_aliased =False, delay_search=True, tag=f"_plot_with"):
            dpg.add_plot_axis(dpg.mvXAxis)


            with dpg.plot_axis(dpg.mvYAxis):
                dpg.add_image_series("texture_tag", [0, 0], [800,800]  )
                
            dpg.add_drag_rect(default_value=(-100, -100, 500, 500),) 



dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

微信截图_20241223235528

@monkeycc monkeycc reopened this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant