QCustomPlot Discussion and Comments

Problem displaying colormap with large number of cellsReturn to overview

I have a colormap in my plot showing a specific pattern which has a large number of cells in value axis (the cells are more than the number of vertical pixels in the colormap height).

Now every time the plot widget's size is changed (the plot is in a layout), a different pattern is shown on the colormap and makes it loop weird like it's showing random data on each size change action. It looks like it's a result of the sampling algorithm that takes different cells on each size change. The code is as :

colorMap->data()->setSize(1000, 6000);
for (int xIndex=0; xIndex<1000; ++xIndex)
{
    for (int yIndex=0; yIndex<6000; ++yIndex)
    {
        double z = (yIndex%100 == 0 ? 5 : 0) ;
        colorMap->data()->setCell(xIndex, yIndex, z);
    }
}

Actually that is a simple code showing the problem. In my real application there is a high resolution spectrogram with large number of cells with the ability to zoom. The parts that has a pattern which looks like the example is displayed weirdly when the plot is zoomed a bit or it's size is changed or even when the values are shifted downward. (Every time shifted different cells are shown)

Is there any solution to this?

It's a moiree-effect which is most prominent with non-interpolated scaling. Did you try setInterpolate(true) on the colormap?

I have also tried it with setInterpolate(true). There is no difference. I don't think it's a moiree-effect. Looks like a problem in sampling. Because when you change the size even in one pixel, all of a sudden you see a completely different colormap.

This is an urgent problem. Did you find a solution?

In fact, this may be caused by the scaling of QImage. The actual size of QImage is (1000, 6000). When the plot is scaled, the actual drawn size will change. At this time, QImage will scale to fit the actual drawn size
see painter->drawImage(QRect, QImage)

So colormap should draw QImage by real size ?