4bb4/implot-rs

Linked plots not properly loading "min" value

dbr opened this issue · 3 comments

dbr commented

If I change implot-examples/examples-shared/src/line_plots.rs as follows,

     pub fn new() -> Self {
         Self {
-            linked_limits: Rc::new(RefCell::new(ImPlotRange { Min: 0.0, Max: 1.0 })),
+            linked_limits: Rc::new(RefCell::new(ImPlotRange { Min: 100.0, Max: 200.0 })),
         }
     }

The Min value is not loaded, and instead the plot defaults to the range 0..200. Same happens with linked_x_limits. Most confusingly, with Min: -100.0 things work as expected

dbr commented

Ah interesting, if in plot.rs I log

if ! y_limit_pointers[0].0.is_null() {
    dbg!(*y_limit_pointers[0].0);
}

..then for one frame the plot is at the desired value before resetting to 0.0

dbr commented

Aha same weirdness happens if I modify implot_demo.cpp, so not a problem with implot-rs!

dbr commented

Caused by epezent/implot#205

We introduced a feature where plots automatically fit to the data on initialization unless SetNextPlotLimits is explicitly called. You do call this function before the first plot, but you also link the x-limits to the second plot where you do not call it. So the second plot is fit to ~[0,10] on initialization and this propagates to the first plot. The simple fix for you right now is to add ImPlotAxisFlags_NoInitialFit to the x-axis of both plots. However, this is an obvious oversight on my part. I need to disable auto-fit on initialization if LinkNextPlotLimits is called. Give me a few hours and it should be fixed.

..and is fixed in epezent/implot@27bc59e which is part of implot 0.10 and onwards