QCustomPlot Discussion and Comments

Axis Y jumpsReturn to overview

I have a problem - when I do the scaling on the Y axis, this axis jumps left and right because the tick labels on the axis are changed in length (values ​​vary from integer to fractional, such as 32 -> 32,456). Is it possible to do the size of tick label as a constant, predetermined length and Y axis won't jump?

Thanks in advance

I think "setNumberFormat" and setNumberPrecision is what you are looking for.
I hope this helps.

When the tick labels and QCPAxisRect's margins are both set to auto, you get the effect you describe as undesirable. You can either set the format and precission as Bennj suggests, or you can generate the ticks yourself (meither of these methods will get you rid of the axis rocking, but both can improve your user experience considerably if your situation is favourable). Or you can set one or more margins to fixed value (something similar to your original proposal of labels of constant length), which brings a little risk of your labels' dimensions exceeding the preset margin.

These are the methods you are looking for if you want to set fixed margin.

QCPAxisRect::setMargins (const QMargins &margins)
QCPAxisRect::setMinimumMargins (const QMargins &margins)
QCPAxisRect::setAutoMargins (QCP::MarginSides sides)

Thanks, this was a very useful hint. I wanted to solve the same problem since I stack QCusomPlot widgets vertically with the same time scale. I needed the axis tick labels to take up the same amount of width. Here is my solution.

 axisRect()->setAutoMargins(QCP::msRight | QCP::msTop | QCP::msBottom);
    width("000000000"), 0, 0, 0));