hoffstadt / hoffstadt/DearPyGui

mouse pos in plot and axis limit range

Open
#1,028 5 comments 0 reactions 0 assignees View on GitHub
category: plots state: invalid
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 0.816
Operating System: Windows 10

## My Issue/Question
I do not think you fix in https://github.com/hoffstadt/DearPyGui/issues/912#issuecomment-875196074

```python
mouse_x, mouse_y = dpg.get_plot_mouse_pos()
ymin, ymax = dpg.get_axis_limits(self.plot_axis_y)
xmin, xmax = dpg.get_axis_limits(self.plot_axis_x)
```
`mouse_x` will always larger than `xmin`
`mouse_y` will always larger than `ymin`

## To Reproduce
use add_mouse_wheel_handler to print

dpg.get_plot_mouse_pos()
dpg.get_axis_limits(self.plot_axis_y)
dpg.get_axis_limits(self.plot_axis_x)

## Expected behavior

`mouse_x` should less than `xmin` when mouse in y axis left side
`mouse_y` should less than `ymin` when mouse below x axis

## Screenshots/Video

![Snipaste_2021-07-07_09-49-01](https://user-images.githubusercontent.com/26370840/124688152-e040af00-df08-11eb-9d0e-ec94b1ebd753.png)

## Standalone, minimal, complete and verifiable example

```python
from math import cos, pi, sin
import dearpygui.dearpygui as dpg

with dpg.window(label="Label", width=800, height=600):
with dpg.plot(label="plot_name", width=-1, height=-1):
dpg.add_plot_legend()
plot_axis_x = dpg.add_plot_axis(dpg.mvXAxis, label="")
plot_axis_y = dpg.add_plot_axis(dpg.mvYAxis, label="")
plot_id = dpg.last_item()
series_id_1 = dpg.add_line_series(list(range(5)), list(cos(i * pi / 100) for i in range(5)), label="Test 1", parent=plot_id, contribute_to_bounds=False)

def on_mouse_wheel_callback(sender, app_data):
mouse_x, mouse_y = dpg.get_plot_mouse_pos()
ymin, ymax = dpg.get_axis_limits(plot_axis_y)
print(f"ymin {ymin} mouse_y {mouse_y} {mouse_y < ymin}")

with dpg.handler_registry():
dpg.add_mouse_wheel_handler(callback=on_mouse_wheel_callback)

dpg.start_dearpygui()
```

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.