QCustomPlot: построение двух цветовых карт — исчезают оси и деления

как следует из названия, я хочу построить две цветовые карты. Я хочу вывести их в одно и то же окно, но в разные оси. Друг на друга. Что происходит, так это то, что первая цветовая карта нарисована хорошо, а вторая перекрывает большинство осей и делений и выглядит просто ужасно. Вот минимальный рабочий пример:

    QCustomPlot * pCstmPlt = new QCustomPlot;
    pCstmPlt->show();
    QCPAxisRect *axisRect = pCstmPlt->axisRect(0);
    axisRect->setupFullAxesBox(true);

    QCPColorMap *colorMap = new QCPColorMap(axisRect->axis(QCPAxis::atBottom),axisRect->axis(QCPAxis::atLeft));
    int Clrny = 100;
    int Clrnx = 100;
    colorMap->data()->setSize(Clrnx, Clrny);
    colorMap->data()->setRange( QCPRange( 1,100 ), QCPRange( 1,100 ) );
    double x, y, dVal;
    for (int xIndex=0; xIndex<100; ++xIndex)
    {
        for (int yIndex=0; yIndex<100; ++yIndex)
        {
            colorMap->data()->cellToCoord(xIndex, yIndex, &x, &y);
            dVal = ( xIndex * yIndex );
            colorMap->data()->setCell(xIndex, yIndex, dVal);
        }
    }
    // add a color scale:
    QCPColorScale *pmycolorScale = new QCPColorScale(pCstmPlt);
    pCstmPlt->plotLayout()->addElement(0, 1, pmycolorScale);
    pmycolorScale->setType(QCPAxis::atRight);
    colorMap->setColorScale(pmycolorScale);
    colorMap->setGradient( QCPColorGradient::gpPolar );

    axisRect = new QCPAxisRect(pCstmPlt,true);
    axisRect->setupFullAxesBox(true);
    pCstmPlt->plotLayout()->addElement(1,0,axisRect);
    QCPColorMap *colorMap2 = new QCPColorMap(axisRect->axis(QCPAxis::atBottom),axisRect->axis(QCPAxis::atLeft));
    colorMap2->data()->setSize(Clrnx, Clrny);
    colorMap2->data()->setRange( QCPRange( 1,100 ), QCPRange( 1,100 ) );
    for (int xIndex=0; xIndex<100; ++xIndex)
    {
        for (int yIndex=0; yIndex<100; ++yIndex)
        {
            colorMap2->data()->cellToCoord(xIndex, yIndex, &x, &y);
            dVal = ( xIndex * yIndex );
            colorMap2->data()->setCell(xIndex, yIndex, dVal);
        }
    }
    // add a color scale:
    QCPColorScale *pmycolorScale2 = new QCPColorScale(pCstmPlt);
    pCstmPlt->plotLayout()->addElement(1, 1, pmycolorScale2);
    pmycolorScale2->setType(QCPAxis::atRight);
    colorMap2->setColorScale(pmycolorScale2);
    colorMap2->setGradient( QCPColorGradient::gpPolar );
    colorMap->rescaleDataRange();
    colorMap2->rescaleDataRange();
    pCstmPlt->rescaleAxes();
    pCstmPlt->setMinimumSize(QSize(500,500));

Результат выглядит следующим образом:

Пример двухцветных графиков

Итак, ясно, что на нижнем графике отсутствуют галочки и оси...

Кто-нибудь знает как это решить???? Спасибо!


person Stefanowitschko    schedule 17.02.2021    source источник


Ответы (1)