RE: Drawing part of a TGraphErrors

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Mon, 19 Feb 2007 17:42:49 +0100


May be something like that would be simpler:  

{

   Int_t n=20;
   Double_t x[n],y[n];
   for (Int_t i=0; i < n; i++) {

      x[i]=i*0.1;
      y[i]=10*sin(x[i]+0.2);

   }
   TGraph *gr1 = new TGraph (n,x,y);
   TAxis *axis = gr1->GetXaxis();
   axis->SetLimits(0.,5.);                 // along X
   gr1->GetHistogram()->SetMaximum(20.);   // along          
   gr1->GetHistogram()->SetMinimum(-20.);  //   Y     

   gr1->Draw("AC*");
}


From: owner-roottalk_at_pcroot.cern.ch
[mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Ann-Cecilie Larsen Sent: Monday, February 19, 2007 5:24 PM
To: RootTalk
Subject: [ROOT] Drawing part of a TGraphErrors

Dear Rooters,

I am trying to plot only a part of a graph with error bars using the following statements in my macro:

// make graph

TGraphErrors *gr_fg3 = new TGraphErrors(n,energy,fg3,xerr,fgerr3); // for fg
// creating histogram (just for the axis)
TH2F *h1 = new TH2F("h1"," ",10,0.0,8.0,10,0.0,1.0); h1->Draw(); // draw axis

gr_fg3->SetMarkerStyle(21);
gr_fg3->SetMarkerSize(0.6);
gr_fg3.DrawGraph(8,&gr_fg3->GetX()[5],&gr_fg3->GetY()[5],"P"); // draw
fg data

But the error bars disappear in the pad... Is there another function than DrawGraph that should be used with the TGraphErrors?

Cheers, Cecilie


Ann-Cecilie Larsen

Oslo Cyclotron Laboratory (http://ocl.uio.no/)

Department of Physics, University of Oslo

P.O.Box 1048 Blindern

N-0316 Oslo, Norway

Phone: +47 22 85 64 63 Fax: +47 22 85 64 22

E-mail: a.c.larsen_at_fys.uio.no


Received on Mon Feb 19 2007 - 17:43:16 CET

This archive was generated by hypermail 2.2.0 : Mon Feb 19 2007 - 23:50:01 CET