hoffstadt / hoffstadt/DearPyGui

Updating x-axis minimum and maximum value with time data

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

Description

Hello,

As far as I can tell from the documentation, it is not possible to fix the maximum and minimum values of an x-axis for an line_series plot, if the x-axis has time=True. The closest I get is dpg.set_axis_limits(axis, ymin, ymax), however it does not work properly on x-axis objects, when it is formatted as a time series.

I would like to be able to do this.

**Minimum reproducible code**
```
import dearpygui.dearpygui as dpg
import time
from math import sin

dpg.create_context()
dpg.create_viewport(title='CSV Reader', width=1020, height=580)

time_now = time.time()
tmin = time_now-20
tmax = time_now+20

def sindata():
sindatax = []
sindatay = []
for i in range(0, 100):
sindatax.append(time_now+i)
sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
return sindatax, sindatay

sindatax, sindatay = sindata()

with dpg.window(label="Main Window", width=1080, height=500):
with dpg.plot(label="Plot",height=490, width=900):
dpg.add_plot_axis(dpg.mvXAxis, label="x", tag='xaxis', time=True)
ax_y1 = dpg.add_plot_axis(dpg.mvYAxis, tag='yaxis')
dpg.add_line_series(sindatax, sindatay, label="sin", tag='datay', parent=dpg.last_item())
dpg.set_axis_limits('xaxis', tmin,tmax)


dpg.setup_dearpygui()
dpg.show_viewport(maximized=True)
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.