The plot line is not visible at the maximum and minimum y-values
Version of Dear PyGui
Version: 2.0.0 Python: 3.12.9 Operating System: Windows 11
Issue
The plot line is not visible at the maximum and minimum y-values
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title="Simple DearPyGUI Plot", width=600, height=400)
x_data = [0, 1, 2, 3, 4, 5]
y_data = [0, 0, 0, 1, 1, 1]
with dpg.window(label="Plot Example", width=580, height=380):
with dpg.plot(label="Line Plot", height=-1, width=-1):
dpg.add_plot_axis(dpg.mvXAxis, label="X Axis")
y_axis = dpg.add_plot_axis(dpg.mvYAxis, label="Y Axis", tag='yax')
dpg.add_line_series(x_data, y_data, label="Line Series", parent=y_axis)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Expected behavior
using workaround
if rng := max(y_data)-min(y_data) > 0:
dpg.set_axis_limits('yax', min(y_data)-0.1*rng, max(y_data)+0.1*rng)
How would DPG (or ImPlot) know how much space your want to leave around the plot? (ImPlot is the library that DPG uses to render plots). Surely we can make that configurable, but so far ImPlot itself does not provide such controls, and DPG mostly follows ImPlot capabilities so that it's easier to upgrade to newer ImPlot versions. As you pointed out, it's relatively easy to implement autofitting on application side the way you need it.
It is not necessary to add space, but the plot lines that coincide with the border are simply not visible. Thanks, I will address questions about plots to ImPlot