I am using root 5.34/38 (this is what is returned when I punch in gROOT->GetVersion() )
I have an array of 12 TGraphs called g and an array of 6 TMultiGraphs called mg. The goal is to plot two of the TGraphs in each of the 6 TMultiGraphs and plot all 6 multigraphs on a single page. I initialize the canvas with:
Later, I make the TGraphs using methods that are not found in native ROOT (we have some custom software). The TGraphs are made just fine and are successfully stored in the array g.
To make all the multigraphs, I have:
for(int j = 0; j < 6; j++){
c1->cd(j+1);
mg[j] = new TMultiGraph();
mg[j]->Add(g[j]);
mg[j]->Add(g[j+6]);
mg[j]->Draw("AP");
mg[j]->SetTitle(Form("This is a dummy Title"));
}
gPad->BuildLegend();
gPad->SetGrid();
c1->SaveAs(Form("%s/Channel_%03d.pdf",strOutPath.Data(),ch));
However, when I plot this, I get a single TGraph in my pdf file, not 6. What am I missing?
See if you do not “Draw” something in another place (note also that all “gPad” calls should go inside of the “for” loop).
Before “c1->SaveAs(...);” add “c1->cd(0);”
I managed to make this work by simply removing the g[j]->Draw(“ap”) lines. Thank you both for helping me with this. My sincerest gratitude to both of you.