I’ve been trying to draw a TMultiGraph() in a TCanvas(), which is subdivided in 3.
Somehow, this does not seem to work entirely for me…
I have a loop, which draws each TMultiGraph in its designated pad. I then update the canvas within the same loop with c->Update(). I labled the X/Y-axis and then used c->Modified();
I can see that the MultiGraph has been drawn. However, it disappears in the next iteration and the new MultiGraph is displayed on the pad (this happens in all iterations).
I do not understand why this happens:
I have declared an array: TMultiGraphs ()* mg[3]
added different TGraphs: mg[0]->Add(gr0);mg[1]->Add(gr1);mg[2]->Add(gr2);
drawn it & updated the canvas: mg[ii]->Draw(“ap”); c->Update();
It is difficult to tell what is wrong. A small macro reproducing your problem might help to understand. It seems you forgot some “cd()” in the pad you want to Draw (before drawing the multigraph).
Thx for the response. I managed to resolve the issue. My issue did not stem by forgetting “cd()”.
I was extracting gr0/gr1/gr2 from a function. Earlier, this was done with a reference. I changed this to a pointer.
In addition, I discovered that the graphs were overlayed on top of an empty TH2D- histogram (al within the same pad).
I’ve never seen anything like this and thus removed it too (legacy codes are truly a pain in the ass).
Finally, I changed the command leg->DrawCopy() to leg->Draw()
Everything has been working properly ever since.