ROOT
Version v6.34
master
v6.36
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
graphApply.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphs
3
/// \notebook
4
/// A macro to demonstrate the functionality of TGraph::Apply() method.
5
/// TGraph::Apply applies a function `f` to all the data TGraph points.
6
/// `f` may be a 1-D function TF1 or 2-d function TF2.
7
/// The Y values of the graph are replaced by the new values computed using
8
/// the function.
9
///
10
/// \macro_image
11
/// \macro_code
12
///
13
/// \author Miro Helbich
14
15
void
graphApply
()
16
{
17
const
Int_t
npoints
=3;
18
Double_t
xaxis
[
npoints
] = {1.,2.,3.};
19
Double_t
yaxis
[
npoints
] = {10.,20.,30.};
20
Double_t
errorx
[
npoints
] = {0.5,0.5,0.5};
21
Double_t
errory
[
npoints
] = {5.,5.,5.};
22
23
Double_t
exl
[
npoints
] = {0.5,0.5,0.5};
24
Double_t
exh
[
npoints
] = {0.5,0.5,0.5};
25
Double_t
eyl
[
npoints
] = {5.,5.,5.};
26
Double_t
eyh
[
npoints
] = {5.,5.,5.};
27
28
TGraph
*
gr1
=
new
TGraph
(
npoints
,
xaxis
,
yaxis
);
29
TGraphErrors
*
gr2
=
new
TGraphErrors
(
npoints
,
xaxis
,
yaxis
,
errorx
,
errory
);
30
TGraphAsymmErrors
*
gr3
=
new
TGraphAsymmErrors
(
npoints
,
xaxis
,
yaxis
,
exl
,
exh
,
eyl
,
eyh
);
31
TF2
*
ff
=
new
TF2
(
"ff"
,
"-1./y"
);
32
33
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"c1"
);
34
c1
->Divide(2,3);
35
36
// TGraph
37
c1
->cd(1);
38
gr1
->DrawClone(
"A*"
);
39
c1
->cd(2);
40
gr1
->Apply(
ff
);
41
gr1
->Draw(
"A*"
);
42
43
// TGraphErrors
44
c1
->cd(3);
45
gr2
->DrawClone(
"A*"
);
46
c1
->cd(4);
47
gr2
->Apply(
ff
);
48
gr2
->Draw(
"A*"
);
49
50
// TGraphAsymmErrors
51
c1
->cd(5);
52
gr3
->DrawClone(
"A*"
);
53
c1
->cd(6);
54
gr3
->Apply(
ff
);
55
gr3
->Draw(
"A*"
);
56
}
Int_t
int Int_t
Definition
RtypesCore.h:45
Double_t
double Double_t
Definition
RtypesCore.h:59
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF2
A 2-Dim function with parameters.
Definition
TF2.h:29
TGraphAsymmErrors
TGraph with asymmetric error bars.
Definition
TGraphAsymmErrors.h:26
TGraphErrors
A TGraphErrors is a TGraph with error bars.
Definition
TGraphErrors.h:26
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition
TGraph.h:41
c1
return c1
Definition
legend1.C:41
tutorials
graphs
graphApply.C
ROOT v6-34 - Reference Guide Generated on Mon Apr 21 2025 16:53:49 (GVA Time) using Doxygen 1.10.0