Good day, I'm trying to plot a color map (see the part of the code below), but the plotted data doesn't match the colorgradient somehow, what could be a problem?
int nx=55, ny=25; customPlot->axisRect()->setupFullAxesBox(true); customPlot->yAxis->setLabel("Y, cm"); customPlot->xAxis->setLabel("X, cm"); customPlot->xAxis->setRange(-3500, 2000); customPlot->yAxis->setRange(-500, 2000); QCPColorMap *Colormap = new QCPColorMap (customPlot-> xAxis, customPlot-> yAxis); Colormap-> data () -> setSize (nx, ny); Colormap-> data () -> setRange (QCPRange (-3500 + 50, 1900 + 50), QCPRange (-500 + 50, 1900 + 50)); Colormap-> setInterpolate (false); Colormap-> setTightBoundary(false); for (int y = 0; y < ny; ++y) { for (int x = 0; x < nx; ++x) { double z = QRandomGenerator::global()->generateDouble(); if (z) Colormap-> data () -> setCell (x, y, z*1e5); else Colormap-> data () -> setAlpha (x, y, 0); } } QCPColorScale *colorScale = new QCPColorScale (customPlot); colorScale-> setType (QCPAxis :: atBottom); customPlot-> plotLayout () -> addElement (1, 0, colorScale); QCPRange range(1e-4,1e7); colorScale->axis()->setRange(range); colorScale->axis()->setScaleType (QCPAxis::stLogarithmic ); colorScale->axis()->setNumberPrecision(0); colorScale->axis()->setNumberFormat("eb"); QCPColorGradient gradient; QVector<QColor> mycolorsset1; mycolorsset1.append(QColor(255, 255, 255)); mycolorsset1.append(QColor(253, 105, 253)); mycolorsset1.append(QColor(181, 0, 255));mycolorsset1.append(QColor(6, 0, 204)); mycolorsset1.append(QColor(0, 147, 255)); mycolorsset1.append(QColor(0, 179, 132));mycolorsset1.append(QColor(124, 254, 1));mycolorsset1.append(QColor(254, 255, 0)); mycolorsset1.append(QColor(255, 129, 0));mycolorsset1.append(QColor(204, 0, 0));mycolorsset1.append(QColor(0, 0, 0)); gradient.clearColorStops();gradient.setLevelCount(11); for(qint16 i=1;i<12;++i) { if(i==1) {gradient.setColorStopAt(0, mycolorsset1[i-1]);gradient.setColorStopAt((double)i/11, mycolorsset1[i-1]);} else if(i<mycolorsset1.length()) {gradient.setColorStopAt((double)(i-1)/11+1e-12, mycolorsset1[i-1]);gradient.setColorStopAt((double)i/11-1e-12, mycolorsset1[i-1]);} else {gradient.setColorStopAt((double)(i-1)/11, mycolorsset1[i-1]);gradient.setColorStopAt(1, mycolorsset1[i-1]);} } Colormap->setColorScale(colorScale); Colormap->setGradient(gradient); QSharedPointer<QCPAxisTickerLog> logTicker(new QCPAxisTickerLog); colorScale->axis()->setTicker(logTicker); logTicker->setTickCount(11); // QCPMarginGroup *marginGroup = new QCPMarginGroup(customPlot); customPlot->axisRect()->setMarginGroup(QCP::msLeft | QCP::msRight, marginGroup); colorScale->setMarginGroup(QCP::msLeft | QCP::msRight, marginGroup);