Hi, quick question: I am trying to draw a multigraph on a canvas in a loop, which means it should always delete the previous plot before drawing the new ones on the canvas. My code looks something like this:
....
TMultiGraph* multiGraph = new TMultiGraph();
while (true) {
for (Int_t i = 0; iSample < branchNames.size(); ++i) {
// get the branch of my tree
// get the leaf (each entry is an array of floats)
// create new graph
}
for (Int_t j = 0; j < arrayLength; ++j){
// set points of graph with values of the entry's array
}
// add graph to multigraph
}
multiGraph->Draw("AL");
canvas->Update()
....
So basically each new iteration of the while loop, the canvas should be cleared from the previous plots/graphs. I have tried everything, i.e. putting
multigraph->Clear();
canvas->Clear();
canvas->Modified();
In different combinations in different places of the code but nothing seems to work. It keeps overlaying the plots. The only thing that works is creating a new instance of multigraph each new iteration of the loop. But that does not seem like an efficient elegant way.