QCustomPlot Discussion and Comments

Plot not showing up after button pushedReturn to overview

Hi there,

I'm currently new to this tool and is playing with the provided demos. I find if I add a push button connecting to these demos, after I clicking the button, the plots won't show up right away, and I have to perform some operations like dragging or zooming in/out to make the plot show up. But if I take off the push button, these plots show up right away. Also adding a replot at the end of the demo can also make plot showing up right after pushing the button without dragging/zooming.

Is the plot not showing up right after clicking the push button normal? Or is there any way to make the plot show up after clicking the push button without adding replot?

Thanks!

Plots not updating after changing their contents right away are perfectly normal.
You need to call "replot()" to update graphs.
In example below, as you see - the plots need to be updated manually by calling "replot()". Without it nothing changes until you perform a range changing action over the plot, which presumably also calls "replot()" in some way...

void heat_map_widget::updateHeatMap()
{
    // section of setting data on the heatMap:
    heatMap->data()->clear();
    // size
    heatMap->data()->setSize(rozmiarX, rozmiarY);
    // data range - od lowest do highest
    double minVelocity = dataTable->velocityTable[minObsNumber][minRangeVelIndex];
    double maxVelocity = dataTable->velocityTable[minObsNumber][maxRangeVelIndex];
    // size
    if (rozmiarX != 1) // "rozmiar" means "size" :D
        heatMap->data()->setRange(QCPRange(minObsNumber, maxObsNumber), QCPRange(minVelocity, maxVelocity ) );
    else
        heatMap->data()->setRange(QCPRange(-0.5, 0.5), QCPRange(minVelocity, maxVelocity ) );
    // we take proper tables from dataTable
    std::vector < std::vector < double > > *poltab = getPoltab();
    std::vector < double > *errtab = getErrtab();
    std::vector < double > *normtab = getNormtab();
    // we fill heat map
    for (unsigned long int indexWX = 0; indexWX < rozmiarX; indexWX++)
    {
        double normCoeff = (*normtab)[minObsNumber + indexWX];
        for (unsigned long int indexWY = 0; indexWY < rozmiarY; indexWY++)
        {
            if(!normalizationB)
                heatMap->data()->setCell(indexWX, indexWY, (*poltab)[minObsNumber+indexWX][minRangeVelIndex + indexWY]);
            else
                heatMap->data()->setCell(indexWX, indexWY, (*poltab)[minObsNumber+indexWX][minRangeVelIndex + indexWY] / normCoeff);
        }
    }
    // we rescale heat map
    scaleHeatMap(); // my custom method
    // we update other plots
    plotSingleSpectrum(xIndex, yIndex);
    plotLCS(xIndex, yIndex, *errtab);
    setLabelClicked(xIndex, yIndex);
    // we replot at the end
    heatMapPlot->replot();
    colorbarWidget->replot();
    spectrumPlot->replot();
    lcsPlot->replot();
}

Thanks for the confirming! That's exactly what I thought!