epezent / implot

Immediate Mode Plotting
MIT License
4.79k stars 531 forks source link

[Question] How to set the X and Y axis in the same scale (resolution) #293

Closed Rullec closed 3 years ago

Rullec commented 3 years ago

Hi guys! Thanks for this amazing work implot, I enjoy it a lot. But one question frasturate me for a whole day: After watching the whole ShowDemo source, I still failed to figure out how can I make my X and Y axis have the same scale. It is say, if my X data range from [0,5], I would like my Y data also range from [0, 5] or [st, ed + 5]

Eager to get your help!

epezent commented 3 years ago

Did you try ImPlotFlags_Equal? This will make x and y have the same aspect ratio (e.g. a circle will always be a circle, never an ellipse). It doesn't necessarily mean x and y have the same min and max, or range, though. To accomplish that, I think you'll need custom logic that sets the axes limits manually, or you may be able to use SetupAxisLinks to link the x-axis to the y-axis directly (this is untested, though).

Rullec commented 3 years ago

Did you try ImPlotFlags_Equal? This will make x and y have the same aspect ratio (e.g. a circle will always be a circle, never an ellipse). It doesn't necessarily mean x and y have the same min and max, or range, though. To accomplish that, I think you'll need custom logic that sets the axes limits manually, or you may be able to use SetupAxisLinks to link the x-axis to the y-axis directly (this is untested, though).

oh, thanks! it solve my problem perfectly. thanks for your quick and helpful advice!