hoffstadt / hoffstadt/DearPyGui

dpg.hide() on plot_axis also hides the legend

Open
#2,319 0 comments 1 reaction 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## 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](https://github.com/hoffstadt/DearPyGui/assets/104593001/83519893-6d19-49fc-b10a-f2bb7e61d191)
Where is my "visible" legend? :)

## Standalone, minimal, complete and verifiable example

```python
#!/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()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.