ROOT logo

From $ROOTSYS/tutorials/graphs/graphApply.C

{
//A macro to demonstrate the functionality of TGraphX::Apply() method
//Author: Miro Helbich oct.2001


Int_t npoints=3;
Double_t xaxis[npoints] = {1.,2.,3.};
Double_t yaxis[npoints] = {10.,20.,30.};
Double_t errorx[npoints] = {0.5,0.5,0.5};
Double_t errory[npoints] = {5.,5.,5.};

Double_t exl[npoints] = {0.5,0.5,0.5};
Double_t exh[npoints] = {0.5,0.5,0.5};
Double_t eyl[npoints] = {5.,5.,5.};
Double_t eyh[npoints] = {5.,5.,5.};

TGraph *gr1 = new TGraph(npoints,xaxis,yaxis);
TGraphErrors *gr2 = new TGraphErrors(npoints,xaxis,yaxis,errorx,errory);
TGraphAsymmErrors *gr3 = new TGraphAsymmErrors(npoints,xaxis,yaxis,exl,exh,eyl,eyh);
TF2 *ff = new TF2("ff","-1./y");

TCanvas *c1 = new TCanvas("c1","c1");
c1->Divide(2,3);
// TGraph
c1->cd(1);
gr1->DrawClone("A*");
c1->cd(2);
gr1->Apply(ff);
gr1->Draw("A*");

// TGraphErrors
c1->cd(3);
gr2->DrawClone("A*");
c1->cd(4);
gr2->Apply(ff);
gr2->Draw("A*");

// TGraphAsymmErrors
c1->cd(5);
gr3->DrawClone("A*");
c1->cd(6);
gr3->Apply(ff);
gr3->Draw("A*");

}
 graphApply.C:1
 graphApply.C:2
 graphApply.C:3
 graphApply.C:4
 graphApply.C:5
 graphApply.C:6
 graphApply.C:7
 graphApply.C:8
 graphApply.C:9
 graphApply.C:10
 graphApply.C:11
 graphApply.C:12
 graphApply.C:13
 graphApply.C:14
 graphApply.C:15
 graphApply.C:16
 graphApply.C:17
 graphApply.C:18
 graphApply.C:19
 graphApply.C:20
 graphApply.C:21
 graphApply.C:22
 graphApply.C:23
 graphApply.C:24
 graphApply.C:25
 graphApply.C:26
 graphApply.C:27
 graphApply.C:28
 graphApply.C:29
 graphApply.C:30
 graphApply.C:31
 graphApply.C:32
 graphApply.C:33
 graphApply.C:34
 graphApply.C:35
 graphApply.C:36
 graphApply.C:37
 graphApply.C:38
 graphApply.C:39
 graphApply.C:40
 graphApply.C:41
 graphApply.C:42
 graphApply.C:43
 graphApply.C:44
 graphApply.C:45
 graphApply.C:46
thumb