QCustomPlot Discussion and Comments

QCPColorScale::setDataScaleType() seems to do nothingReturn to overview

I have created a program that plots the results into a colour map. It works fine, but when I change the colour map's scale to logarithmic (otherwise I can't see much), the legend looks very odd, with values shown at linear intervals (because the scale is logarithmic, they are all massed on the top). If I set both the QCPColorScale and QCPColorMap's data scale type to logarithmic, it still persists. I am using a version that I have downloaded quite recently.

Here is a screenshot of what it does:
http://i.imgur.com/EoRgIxq.png

Am I doing something wrong or there is a bug?

Looking at the code, it appears to do something, but the points where the values on the scale are shown completely ignore the scale and are shown linearly. It appears to be unimplemented functionality.

Turns out that QCPAxisTicker::generate() picks the values where ticks appear are chosen linearly on any axis, with no regard if the axis is linear or logarithmic. It does not even know if the axis is linear or logarithic. They should appear with same distance from each other on the axis shown. It looks quite odd.

Finally, I have found it.

The trick was to set the colorScale's axis' ticker to QCPAxisTickerLog.

The undocumened thing is that this:

colourScale->axis()->setScaleType(QCPAxis::stLogarithmic);
Must always be followed by this:
colourScale->axis()->setTicker(QSharedPointer<QCPAxisTicker>(new QCPAxisTickerLog()));

I hope this will be indexed by google because I do not wish to anyone having to find this in code.

In the documentation of QCPAxis::setScaleType it is explicitly recommended to also use QCPAxisTickerLog:
"Note that this method controls the coordinate transformation. You will likely also want to use a logarithmic tick spacing and labeling, which can be achieved by setting an instance of QCPAxisTickerLog via setTicker. See the documentation of QCPAxisTickerLog about the details of logarithmic axis tick creation."

I've forgotten to also put this info in the documentation of QCPColorScale::setDataScaleType, which you were looking at. It will be added in 2.0, thanks for bringing it up.

Yes, as you guessed, I was looking exactly at that wrong place. There also does not seem to be a single example showing the usage of a logarithmic axis.

Thanks in advance for adding it there.