Tilted, vertical text for ticks on X axes for my plots

456 Views Asked by At

When setting up labels for ticks on my X axes:

ImPlot::SetupAxisTicks(ImAxis_X1, positions, COUNTC, labels);

I would like those to be rendered vertically, or rotated with a specific angle, e.g. to get from:

enter image description here

to this or similar (excuse the blurry GIMP sketch):

enter image description here

I have been looking up "formatter" and "ImPlotAxisFlags" in the source and I am still not clean on how to do that without actually coding a whole new functionality, rotating the text myself. Looking at the online demo, it seems to me perhaps the "tags" formatting could help, yet no dice.

I would appreciate if you could point out either "LOL, use this flag and then this double would be the angle in radians" or if you could confirm that there is no such API and I have to somehow do it myself.

Drawing arbitrary vertical text,

     for(int i =0;i < COUNTC;i++) {
            ImPlot::PlotText(labels[i], i, 7.0f, ImVec2(0,0), ImPlotTextFlags_Vertical);
        }

I achieved this:

enter image description here

...so feels like if I just did it in...the tick formatter it could be the ticks labels?

1

There are 1 best solutions below

0
On

Maybe you can achieve the desired effect by using a custom tick label formatter and drawing the rotated text yourself. See this issue on their repo for examples on how to rotate text.