4bb4/implot-rs

Auto-scaling axis (FitNextPlotAxes)

dbr opened this issue · 1 comments

dbr commented

If I have a graph with some data, by default the X and Y axes show 0-1 ranges. It would be useful to have an easy way to scale the graph to fit the data

There is the FitNextPlotAxes API which does this, but not sure how it would best integrate with the Rust API

The use cases I can think of are:

  1. A button for the user to fit the graph (in either a specific axis like this, or maybe a shortcut to fit all)
  2. A way to have the graph fitted on first display
  3. Same but have the graph always fitted (and not zoomable)
4bb4 commented

by default the X and Y axes show 0-1 ranges

I'm pretty sure if you don't set limits, "fit to data" is the default behavior, which you describe in point 2. If you want point 3, you can lock the axes with the AxisFlags::LOCK_MIN and AxisFlags::LOCK_MAX flags. If you want to manually scale the plot to the data (and have not fixed / locked the axes in code), you can double-click into the plot to do that.

I recommend exploring the (non-Rust) implot demos to see what's possible and how the plots can be interacted with. If that doesn't help, we can also add some more example code that demonstrates the various scaling and axis locking behaviors.