QCustomPlot Discussion and Comments

Problem with QCPMarginGroupReturn to overview

Why doesn't this code work with groups? When the QCPcolorScale element is added, do the groups stop working.
I want the right side to line up with the right side of the colormap
Can you help me pls?

here is a picture - https://ibb.co/mB2RkcF

        colorScale = new QCPColorScale(plot);

        plot->plotLayout()->addElement(0, 1, colorScale);
        colorScale->setType(QCPAxis::atRight);
        qMap->setColorScale(colorScale);
        colorScale->axis()->setLabel("level");

        QCPMarginGroup *marginGroup = new QCPMarginGroup(plot);
        plot->axisRect()->setMarginGroup(QCP::msLeft|QCP::msRight|QCP::msBottom|QCP::msTop, marginGroup);
        colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
        ui->pCustomPlotTop->axisRect()->setMarginGroup(QCP::msLeft|QCP::msRight, marginGroup);

plot->plotLayout->element(0, 0)->setMarginGroup(QCP::msLeft|QCP::msRight, marginGroup)

This doesn't work too.

Does the picture you posted really match the code? You address the color scale at the plotLayout cell (0, 1) but in the picture it is in (1, 1). Or do you insert the other axis rect afterwards with insertRow(0)?

Ah I think I know what you're doing wrong, you have them in separate plot widgets, right? So in your bottom plot you have two columns in the grid layout (left axis rect, right color scale). And in the top one you only have the one column. Of course if you synchronize the margins, that doesn't help because the column borders don't match at all.

You should have all in the same plot for this to work.

I know that if they are on the same CustomPlot, this will work, but I need different CustomPlot to be able to sync with each other. Can this be done somehow?

Maybe you can somehow move the colorscale outside the boundaries of the customplot?