QCustomPlot Discussion and Comments

QCP2 - Share x-axis data for multiple graphsReturn to overview


I'm in a situation where multiple graphs (>10) should share the same x-axis (multiple channels acquired at the same time by a DAQ system). The problem is that each trace can have millions of points, so copying the x-axis for each graph is increasing the memory requirements drastically. Is there a way with QCP2 and QSharedPointers / QCPDataContainers (or by any other means) to use the same pointer for the x-axis, but different pointers for the y-axis in different graphs?

Here is a conceptual example of what I would need:

QVector<double> time;
QVector<double> channel1;
QVector<double> channel2;
customPlot->graph()->setData(&time, &channel1); // Use pointers to data
customPlot->graph()->setData(&time, &channel2); // Use the same x-axis pointer, but different y-axis pointer

In order to reduce the memory footprint.


I'm afraid that's not possible, since a data point (QCPGraphData) carries both his key (x) and value (y) coordinate. A graph's data is thus a collection of QCPGraphData and not a collection of x coordinates and a separate collection of y coordinates.

For your approach you'd thus need to build a plottable based on your own type of data container, which stores the keys and values in separate vectors.

I see. In that case I will stick with QCPGraphData.

Thank you for your really fast reply!