c++qtqcustomplot

why QCPColorMap is not setting my value for QCPRange?


i have a problem with colormap sizing. I set the maximum and minimum x sizes, but when the map is drawn, the right border of the map is larger than the maximum x size that I entered in the code:

qMap->data()->setRange(QCPRange(data->m_xmin, data->m_xmax), QCPRange(data->m_ymin, data->m_ymax));

Why is the value of my variable m _xmax equal to 3004.86, and the map shows a border greater than 3005, probably 3005.5? Similarly with the left side.

this is a picture for better understanding

auto plot = ui->pCustomPlot;
QSize size = data->getSize();

plot->setInteractions(QCP::iRangeDrag|QCP::iRangeZoom);


plot->clearPlottables();

QCPColorMap *qMap = new QCPColorMap(plot->xAxis, plot->yAxis);
qMap->data()->setSize(size.width(),size.height());

qMap->data()->setRange(QCPRange(data->m_xmin, data->m_xmax), QCPRange(data->m_ymin, data->m_ymax));

QVector<QVector<PointRS>> arr(data->getMatrix();



for (int i = 0; i < size.width(); i++)
{
    for (int j = 0; j < size.height(); j++)
    {
        qMap->data()->setCell(i, j, arr[j][i].a);
    }
}

qMap->setGradient(QCPColorGradient::gpHot);
qMap->rescaleDataRange();

plot->xAxis->setLabel("x");

plot->yAxis->setLabel("y");


plot->rescaleAxes();

RescaleCustomPlot();

plot->replot();

Solution

  • Have you tried using setTightBoundary?