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

dpg.hide() on plot_axis also hides the legend #2319

Open
v-ein opened this issue Apr 8, 2024 · 0 comments
Open

dpg.hide() on plot_axis also hides the legend #2319

v-ein opened this issue Apr 8, 2024 · 0 comments
Labels
state: pending not addressed yet type: bug bug

Comments

@v-ein
Copy link
Contributor

v-ein commented Apr 8, 2024

Version of Dear PyGui

Version: 1.11.2
Operating System: Windows 10

My Issue/Question

Basically what the title says. It's not clear why should axis visibility affect legend visibility. Looking at the code, I suspect it was a copy-paste mistake: DearPyGui::set_configuration for mvPlotAxisConfig repeats the code from DearPyGui::set_configuration for mvPlotLegendConfig. One more proof of that is that DearPyGui::OnChildAdded for mvPlotAxis does not update the legend visibility, whereas it does so when mvPlotLegend gets added.

To Reproduce

Steps to reproduce the behavior:

Call dpg.hide() on one of plot axes.

Expected behavior

Axis visibility should not affect the legend in any way.

Screenshots/Video

image
Where is my "visible" legend? :)

Standalone, minimal, complete and verifiable example

#!/usr/local/bin/python3

from math import sin
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title="Test", width=500, height=500)

with dpg.window() as wnd:
    dpg.set_primary_window(dpg.last_item(), True)

    x_data = [x/10 for x in range(0, 200)]
    y_data = [sin(x) for x in x_data]

    with dpg.group(horizontal=True):
        dpg.add_button(label="Show X axis", callback=lambda: dpg.show_item("x-axis"))
        dpg.add_button(label="Hide X axis", callback=lambda: dpg.hide_item("x-axis"))
        dpg.add_button(label="Have fun", callback=lambda: print(f"Is 'plot-legend' visible? {dpg.is_item_shown('plot-legend')}"))

    with dpg.plot(label="Regular plot", width=-1, height=-1):
        dpg.add_plot_legend(tag="plot-legend")
        x_axis = dpg.add_plot_axis(dpg.mvXAxis, label="x", tag="x-axis")
        with dpg.plot_axis(dpg.mvYAxis, label="y") as y_axis:
            dpg.add_line_series(x_data, y_data, label="Line series")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
@v-ein v-ein added state: pending not addressed yet type: bug bug labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

No branches or pull requests

1 participant