QCustomPlot Discussion and Comments

Possible bug in 2.0.0: tick labels of QCPColorScale in logarithmic scaleReturn to overview

Hello,

thanks a lot for your beautiful project. We are really happy with it in our https://github.com/scgmlz/BornAgain project.

Recently we have migrated from 1.3.2 to 2.0.0. It went smooth except that tick labels for color scale now looks bad in logarithmic scale.

This is how it was
http://apps.jcns.fz-juelich.de/src/BornAgain/experimental/intensity_1.3.2.png

This is how it became
http://apps.jcns.fz-juelich.de/src/BornAgain/experimental/intensity_2.0.0.png

Reduced example can be just the demo from http://qcustomplot.com/index.php/demos/colormapdemo
where you add following code at the end of file

    colorScale->setDataScaleType(QCPAxis::stLogarithmic);
    colorScale->axis()->setNumberFormat("eb");
    colorScale->axis()->setNumberPrecision(0);
    colorScale->axis()->setScaleType(QCPAxis::stLogarithmic);

and also replace line 23 with

colorMap->data()->setCell(xIndex, yIndex, std::abs(z));

to avoid negative values in amplitudes.

In QCP2, the axis type and ticker are two separate things, have a look at QCPAxis::setScaleType and QCPAxisTickerLog documentation.
In essence, you'll just need to set a QCPAxisTickerLog instance as axis ticker of the color scale's axis, e.g.

QSharedPointer<QCPAxisTickerLog> logTicker(new QCPAxisTickerLog);
colorScale->axis()->setTicker(logTicker);


On a different topic: On your website screenshot at http://www.bornagainproject.org/sites/default/files/screenshots/screenshots_jobview_proj.png
you can see that the left and bottom profile axis rects aren't aligned properly with the main axis rect. You can fix this with QCPMarginGroup.
To prevent the log labels from taking up too much space ("10000"), you can make it display as a power of ten. Quoting the doc of QCPAxisTickerLog: To achieve this, set the number precision (QCPAxis::setNumberPrecision) to zero and the number format (QCPAxis::setNumberFormat) to scientific (exponential) display with beautifully typeset decimal powers, so a format string of "eb"

Thanks a lot, it works!
(Screenshots on our website are 3 years old. Since then we have learned QCPMarginGroup ;). I will replace screenshots with more polished versions.)
Best regards.