Hello everyone!

I use QCustomPlot to draw my graphs and I tried different methods and nothing seems to give me the result I search.

I want to draw multiple graphs, one below the other. The separation between each graph should be the same for all of them.
I also want to be able to change the scale of both the x- and y-axis, keeping the origin of each graph the same (their "0" shouldn't move when rescaling the y-axis). Which also mean that each graph could overlap with the others if needed (this also mean that it can happen that data can go out of the screen, but that's ok).
For the x-axis, I don't have a problem, its quite easy. Its the rescaling of the y-axis that gives me problems...

So here's what I've got for now:

In this first code, I'm able to fix the position of each plot, but I don't see how to change the y-axis scale during execution.
Qt Code:
  1. plot = new QCustomPlot;
  2.  
  3. xAxis.resize(timeScale);
  4. for (int i = 0; i < timeScale; i++)
  5. {
  6. xAxis[i] = i;
  7. }
  8.  
  9. // Offset the data so they're not on top of each other
  10. //--------------------
  11. QCPRange defaultRange(-100., 100.);
  12. for (int i = 0; i < nbPlot; i++)
  13. {
  14. QCPAxis *axis = plot->axisRect()->addAxis(QCPAxis::atLeft);
  15. axis->setRange(defaultRange.lower - (nbPlot - 1 - i) * defaultRange.size(),
  16. defaultRange.upper + i * defaultRange.size());
  17. axis->setVisible(false);
  18.  
  19. QCPGraph *graph = new QCPGraph(plot->xAxis, axis);
  20. }
  21.  
  22. // Set the data to the plot
  23. //--------------------
  24. for (int i = 0; i < plot->graphCount(); i++)
  25. {
  26. plot->graph(i)->setData(xAxis, plotMatrix[i], true);
  27. }
To copy to clipboard, switch view to plain text mode 


In this second code, I offset the data, and I'm able to dynamically change the y-axis during execution. But the graphs's origins aren't fixed, and move when rescaling.
Qt Code:
  1. plot = new QCustomPlot;
  2.  
  3. xAxis.resize(timeScale);
  4. for (int i = 0; i < timeScale; i++)
  5. {
  6. xAxis[i] = i;
  7. }
  8.  
  9. // Set the data to the plot
  10. //--------------------
  11. for (int i=0; i<nbPlot; ++i)
  12. {
  13. plot->addGraph();
  14. // Offset data:
  15. for (int j = 0; j < plotMatrix[i].length(); j++)
  16. {
  17. plotMatrix[i][j] -= (i + 1) * 200;
  18. }
  19. plot->graph()->setData(xAxis, plotMatrix[i]);
  20. plot->graph()->rescaleAxes(true);
  21. }
To copy to clipboard, switch view to plain text mode 

In both cases, the graphs can overlap with the other if the data ask for it. But none of those codes satisfy my needs...

If you have any advice on how to make it or even code example, I'll take it ^^

Have a good day!