Hi all,
I know this has been posted before, but is there a consistent way to draw a TMultiGraph and set the axes limits and titles?
Do you have to Update the canvas after drawing? Do you have to call c->Modified() after setting the limits? The tutorial does not help and previous posts on the ROOT forums are inconsistent. Which out of the confusing mess below will actually work?
Cheers
Alex
TMultiGraph *mg = new TMultiGraph;
mg->SetTitle(title);
mg->Add(g1);
mg->Add(g2);
double xmax1,xmin1,ymax1,ymin1;
double ymax2,ymin2,xmax2,xmin2;
g1->ComputeRange(xmin1,ymin1,xmax1,ymax1);
g2->ComputeRange(xmin2,ymin2,xmax2,ymax2);
mg->GetYaxis()->SetRangeUser(0,std::max(ymax1,ymax2));
mg->SetMaximum(std::max(ymax1,ymax2));
mg->SetMinimum(std::min(ymin1,ymin2));
//c->DrawFrame(xmin1, 0, xmax1, 1.1*std::max(ymax1,ymax2));
mg->Draw("apl");
c->Update();
mg->GetHistogram()->GetXaxis()->SetTitle(xaxis);
mg->GetHistogram()->GetYaxis()->SetTitle(yaxis);
c->Modified();