Re: How to define the x and y axies label on TMultigraph

From: Paraduan Hutauruk <p.hutauruk_at_physics.gla.ac.uk>
Date: Thu, 12 Feb 2009 14:31:43 +0000


I see..so you need to define the axis title after you draw the graph. oke thanks anyway

cheers,
Parada Hutauruk

Olivier Couet wrote:
> ex:
>
> {
> 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();
> }
>
>
>
>
>
>
> On Thu, 12 Feb 2009, Paraduan Hutauruk wrote:
>
>
>> Hi,
>>
>> I tried using the command that you gave but i got the error message when i ran
>> my code. You can see a part of my code and the message error below :
>>
>> TCanvas *c1 = new TCanvas("c1","Extracted Coefficients",200,10,800,350);
>>
>> TGraphErrors *gr5 = new TGraphErrors(nSelected3,energy,a0_M3,0,era0_M3);
>> gr5->SetMarkerColor(kBlue);
>> gr5->SetMarkerStyle(21);
>> TGraphErrors *gr6 = new TGraphErrors(nSelected8,energy,a0s_M3,0,era0s_M3);
>> gr6->SetMarkerColor(kGreen);
>> gr6->SetMarkerStyle(21);
>>
>> // draw multi graph
>> TMultiGraph *mg4 = new TMultiGraph();
>> mg4->Add(gr5);
>> mg4->Add(gr6);
>> mg4->GetXaxis()->SetTitle(" E_{#gamma} (GeV))";
>> mg4->GetYaxis()->SetTitle("Coefficients" );
>> mg4->SetMaximum(2);
>> mg4->SetMinimum(-2);
>> mg4->Draw("AP");
>>
>> root [0] .x pargraph.C
>> Error: illegal pointer to class object GetXaxis() 0x0 470 pargraph.C:274:
>> *** Interpreter error recovered ***
>>
>> Cheers,
>> Parada Hutauruk
>>
>>
>> Olivier Couet wrote:
>>
>>> Hi,
>>>
>>> To set the a multigraph axis titles do:
>>>
>>> Mg->GetXaxis()->SetTitle("x title"); Mg->GetYaxis()->SetTitle("y title");
>>>
>>> Cheers,
>>> O.Couet
>>>
>>> -----Original Message-----
>>> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
>>> On Behalf Of parada hutauruk
>>> Sent: Wednesday, February 11, 2009 6:35 PM
>>> To: roottalk_at_root.cern.ch; Lorenzo Moneta
>>> Subject: [ROOT] How to define the x and y axies label on TMultigraph
>>>
>>> Hi,
>>>
>>> Does anyone help me how to make x and y axis label on TMultigraph?
>>> or can anyone guide me to find it? i tried to look at on manual and
>>> reference guide on website, however i did not find it.
>>>
>>> Cheers,
>>> Parada Hutauruk
>>>
>>>
>>>
>>
>
>
Received on Thu Feb 12 2009 - 15:31:47 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 12 2009 - 17:50:01 CET