QCustomPlot Discussion and Comments

get axis pixel sizeReturn to overview

Does anyone knows how to get the axis pixel size from a QCustomPlot axis ?

Currently I'm using


But this doesn't give me the right value.

I change the source code to have access to calculateMargin function in QCPAxis but this doesn't seem right to me.

other way (but it does not look good):

const QCPRange range = axis->range();
//I do not know why the function returns double
double start = axis->coordToPixel(range.lower);
double end = axis->coordToPixel(range.upper);
double pixelSize = qAbs(end - start);



works correctly for me

I will retry


But for me it didn't give the right value...

are you calling that function before or after the plot has been drawn by qt?