My original motivation is. I have 2 plots in 2 separated QCustomPlot widgets. I want to copy the 2 plots in a single QCustomPlot, so that I can QCusmtomPlot::savePng in a nice and clean way.

I don't know how to "copy" the 2 QCustomPlot into one, so I create a new QCustomPlot, add 2 axesRect, than copy the data into them.

Here is my code:

QCustomPlot * allPlots = new QCustomPlot();

QCPAxisRect * bPlot = new QCPAxisRect(allPlots);

QCPAxisRect * cPlot = new QCPAxisRect(allPlots);
QCPColorMap * cMap = new QCPColorMap(cPlot->axis(QCPAxis::atBottom), cPlot->axis(QCPAxis::atLeft));

The data of the cMap is from an already existed colorMap, I set the data by


The resulting plot, the cMap is on top of the axes ticks. When I checked the layer of cPlot, it shows

(QCPLayoutGrid(0x1d2433781e0), QCPAxisRect(0x1d24345cf60), QCPGrid(0x1d24354d030), QCPAxis(0x1d246fb8240), QCPGrid(0x1d24354cd20), QCPAxis(0x1d246fb8cc0), QCPGrid(0x1d24354cf50), QCPAxis(0x1d246fb8940), QCPGrid(0x1d24354b740), QCPAxis(0x1d246fb8400), QCPAxisRect(0x1d24345d780), QCPGrid(0x1d24354bcf0), QCPAxis(0x1d246fb85c0), QCPGrid(0x1d24354b970), QCPAxis(0x1d246fb8b00), QCPGrid(0x1d24354bc80), QCPAxis(0x1d246fb8780), QCPGrid(0x1d24354d2d0), QCPAxis(0x1d246fb8080), QCPColorMap(0x1d243462190))

The QCPColorMap is always the last one and covered the QCPAxis.

How can I show the axis and the axis ticks on top of the QCPColorMap?
Is there any way to copy 2 QCustomPlot into one?

Thank you very much.