Skip to content

Offset-plus-delta ticking#697

Open
brentfpage wants to merge 1 commit intoepezent:masterfrom
brentfpage:ticks_offset_plus_delta
Open

Offset-plus-delta ticking#697
brentfpage wants to merge 1 commit intoepezent:masterfrom
brentfpage:ticks_offset_plus_delta

Conversation

@brentfpage
Copy link
Copy Markdown

This PR allows for the tick labels on a given axis to be written as a small change (referred to below and in the code as a delta) relative to an offset. This presentation mode is only entered when the axis range=(max-min) is much less than the axis max and min. Specifically, the most significant digit of the axis range must be 3 decimal places to the right of the most significant digit of max(abs(max),abs(min)).
One thing that has to be considered for the mode is the maximum delta size relative to the range. If the maximum delta size is equal to the range, then the delta constantly cycles through 0 and the offset continually changes as the user pans around, which is hard to follow. On the other hand, if the maximum delta size is 1000 times the range, then it has to be written with ~5 sig figs for reasonable precision (range/100), which can lead to crowding. In the PR, the maximum delta size is configured to be between 10 and 100 times the range, avoiding both these issues.
If the delta is not close to 1, then it would have to be written with a bunch of zeros in the absence of any scaling, which would defeat the purpose of the ticking mode. So, the mode also includes a scaling by 10^(3n) such that the range is between 0.01 and 10 "label units".

The ticking mode in action:

  • The default offset-plus-delta presentation, configured using
ImPlot::SetupAxisFormat(ImAxis_X1, ImPlot::Formatter_Offset_Plus_Delta, (void*) "%g");
ImPlot::SetupAxisFormat(ImAxis_Y1, ImPlot::Formatter_Offset_Plus_Delta, (void*) "%g");

:
Screen Recording 2026-04-18 at 7 10 56 PM

  • With the addition of the ImPlotAxisFlag ImPlotAxisFlags_CompactOffsetAndDelta:
Screen Recording 2026-04-18 at 7 09 22 PM

I added this "compact" presentation mode because it's often required on smartphone screens

@brentfpage brentfpage force-pushed the ticks_offset_plus_delta branch from a4d2d2f to 889173d Compare April 19, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant