QCustomPlot Discussion and Comments

Change plot sequence of each graphReturn to overview

I have 8 graphs to be plotted.
I defined the graph data as follow:

QSharedPointer< QCPGraphDataContainer > xyData[8];

After creating 8 graph, I took the data pointer this way:

for(int i=0; i<8; i++)
{
	ui->Plot->axisRect(0)->addAxes(QCPAxis::atLeft);
	[...]
	ui->Plot->addGraph(NULL, ui->Plot->axisRect(0)->axis(QCPAxis::atLeft,i+1));
	xyData[i] = ui->Plot->graph(i)->data();
}

Now, graphs are plotted with sequence 0-1-2-3-4-5-6-7. 7th is on top of others graph and it covers them.
I'd like the graph should be plotted for example with this sequence: 4-8-0-1-2-3-7-5.

So the question: how can I set/change the plot sequence of each graph maintaining unaltered the order of the pointers?

Thanks
Regards
Calzo

QT 5.7, QCP 2.0.0-beta

if you are only doing this once, one way would be to just call setLayer in the order you want. setLayer will automatically change the ordering in the layer,making the one you just called setLayer on to be the last one.

No, actually I have to change the graphs sequence each time I select a track. Selected track must be plotted first.
I need this because the "restlessness" of one track can hide tracks which are plotted before.

So I need a method to change dinamically the sequence.
I tryed to work with layers, but with no success. I'll try again.

[SOLVED]
Probably I have better understood how layers work. I did this way:
- I create 8 axis and added them to graph
- I create 8 new layer called "0", "1",..."7"
- add each graph to his layer

for(int i=0; i<8; i++)
{
	ui->Plot->axisRect(0)->addAxes(QCPAxis::atLeft); 
	[...]
	QString name = QString::number(i);
	ui->Plot->addLayer(name);
	ui->Plot->addGraph(NULL, ui->Plot->axisRect(0)->axis(QCPAxis::atLeft,i+1));
	ui->Plot->graph(i)->setLayer(name);
}
Now, when i select a track, I have to move only the layer down the last one to plot this track over the others:
QCPLayer *l = ui->Plot->layer(QString::number(ui->tableParameters->selectedItems().at(0)->row()));
if(l)
	ui->Plot->moveLayer(l, ui->Plot->layer(ui->Plot->layerCount()-1));

That's it. I don't know if this way is the best one, however it seems to me I have no loss in performances, so in my opinion it works fine.

Thanks
Calzo