loicus
February 3, 2010, 9:16am
1
Hi…
I have the usual question…
How to define the TMultiGraphRange…
(I am fighting since more than one hour now)
I’ve tried:
TCanvas* c1 = new TCanvas("S", "S",800,600);
TMultiGraph *mg = new TMultiGraph();
mg->Add(TFinal800,"LP");
mg->Add(TFinal500,"LP");
mg->Add(TFinal300,"LP");
mg->Add(TFinal200,"LP");
mg->Add(TFinal130,"LP");
mg->Draw("A");
mg->SetMinimum(0);
mg->GetXaxis()->SetTitle("Integrated Luminosity (Pb^{-1})");
mg->GetYaxis()->SetTitle("Estimated Significance");
c1->SetLogx(true);
c1->Modified(); c1->Update();
mg->GetXaxis()->SetRange(0.5,1500);
but does’nt give the expected result…
Can you tell me the exact procedure?
note the .C file generated by TCanvas::SaveAs() is available here:
~querten/public/Final_SignificanceCurveNoSign.C
thanks in advance,
Loic
couet
February 3, 2010, 9:30am
2
Example:
{
TGraph *g[3];
Double_t x[10] = {0,1,2,3,4,5,6,7,8,9};
Double_t y[10] = {1,2,3,4,5,5,4,3,2,1};
TMultiGraph *mg = new TMultiGraph();
for (int i=0; i<3; i++) {
g[i] = new TGraph(10, x, y);
g[i]->SetMarkerStyle(20);
g[i]->SetMarkerColor(i+2);
for (int j=0; j<10; j++) y[j] = y[j]-1;
mg->Add(g[i]);
}
mg->Draw("AP");
mg->GetXaxis()->SetTitle("E_{#gamma} (GeV)");
mg->GetYaxis()->SetTitle("Coefficients");
gPad->Modified();
mg->GetXaxis()->SetRange(29,65);
}
You can also define a Frame with
gPad->DrawFrame(…) and draw the multigraph without option A
loicus
February 3, 2010, 12:54pm
3
thanks the DrawFrame method works…
the other one is basically what I’ve tried already (Or am I missing something?)
Loic,
couet
February 3, 2010, 1:47pm
4
Well, both are working for me.
Loic,
What has worked for me is
mg -> Draw(“alp”);
mg -> GetXaxis() -> SetRangeUser(4,54);
gPad -> Modified();
In your example code you have the gPad -> Modified() before setting the range. Try placing it after.
-S