ROOT
Version v6.34
master
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
ROOT Reference Documentation
Tutorials
▼
Functional Parts
►
Core ROOT classes
►
std Extension classes
►
Parallelized classes
►
The Geometry Package
►
Graphics
►
Event display with ROOT7
►
GUI
►
Web Widgets
►
Web Display
►
Histogram Library
►
Input/Output Library
►
Math
►
N-D parametric functions
►
VecOps
►
Monte Carlo
►
HTTP server
►
PROOF
►
TMVA
►
RooFit
►
Dataframe
►
ROOT7 classes
►
NTuple-related classes
►
Tree Library
►
TreePlayer Library
▼
Tutorials
►
Histograms tutorials
►
Tree tutorials
►
Dataframe tutorials
►
ROOT 7 tutorials
►
FOAM tutorials
►
Containers tutorials
►
Event display tutorials
►
Event display ROOT7 tutorials
►
Geometry tutorials
►
Fast Fourier Transforms tutorials
►
Fit Tutorials
►
RooFit Tutorials
▼
Graphs tutorials
annotation3d.C
approx.C
bent.C
bent.py
exclusiongraph.C
exclusiongraph2.C
gerrors.C
gerrors2.C
gmultierrors.C
graph.C
graph2derrorsfit.C
graphApply.C
graphpalettecolor.C
graphpolar.C
graphpolar2.C
graphpolar3.C
graphreverse.C
graphShade.C
graphstruct.C
graphtext.C
gtime.C
gtime2.C
hlGraph1.C
hlGraph2.C
labels1.C
labels2.C
motorcycle.C
multigraph.C
multigraphpalettecolor.C
multipalette.C
scatter.C
seism.C
splines_test.C
surfaces.C
timeonaxis.C
timeonaxis2.C
timeonaxis3.C
timeSeriesFromCSV.C
timeSeriesFromCSV.py
timeSeriesFromCSV_TDF.C
waves.C
zdemo.C
zones.C
zones.py
►
Graphics tutorials
►
OpenGL tutorials
►
Tutorials specific to Mac/Cocoa
►
GUI tutorials
►
HistFactory Tutorials
►
HTTP tutorials
►
Image tutorials
►
IO tutorials
►
Math tutorials
►
Matrix tutorials
►
Monte Carlo tutorials
►
Multicore tutorials
►
Net tutorials
►
Physics tutorials
►
PyRoot tutorials
►
Pythia tutorials
►
Quadratic programming package.
►
R tutorials
►
RooStats Tutorials
►
Spectrum tutorials
►
TSPlot tutorials
►
SQL tutorials
►
TMVA tutorials
►
TUnfold tutorials
►
Unuran tutorials
►
VecOps tutorials
►
FITS files interface tutorials
►
XML tutorials
►
Proof tutorials
►
TWebCanvas tutorials
►
Webgui tutorials
►
Legacy tutorials
demos.C
demoshelp.C
hsimple.C
rootlogoff.C
rootlogon.C
►
R Interface for Statistical Computing
►
Namespaces
►
All Classes
►
Files
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
multigraph.C File Reference
Tutorials
»
Graphs tutorials
Detailed Description
Create and Draw a
TMultiGraph
.
void
multigraph
()
{
gStyle
->
SetOptFit
();
auto
c1
=
new
TCanvas
(
"c1"
,
"multigraph"
,700,500);
c1
->SetGrid();
// draw a frame to define the range
auto
mg =
new
TMultiGraph
();
// create first graph
const
Int_t
n1
= 10;
Double_t
px1[] = {-0.1, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
Double_t
py1[] = {-1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
Double_t
ex1
[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
Double_t
ey1
[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
auto
gr1
=
new
TGraphErrors
(
n1
,px1,py1,
ex1
,
ey1
);
gr1
->SetMarkerColor(
kBlue
);
gr1
->SetMarkerStyle(21);
gr1
->Fit(
"gaus"
,
"q"
);
auto
func1
= (
TF1
*)
gr1
->GetListOfFunctions()->FindObject(
"gaus"
);
func1
->SetLineColor(
kBlue
);
mg->Add(
gr1
);
// create second graph
const
Int_t
n2
= 10;
Float_t
x2
[] = {-0.28, 0.005, 0.19, 0.29, 0.45, 0.56,0.65,0.80,0.90,1.01};
Float_t
y2
[] = {2.1,3.86,7,9,10,10.55,9.64,7.26,5.42,2};
Float_t
ex2
[] = {.04,.12,.08,.06,.05,.04,.07,.06,.08,.04};
Float_t
ey2
[] = {.6,.8,.7,.4,.3,.3,.4,.5,.6,.7};
auto
gr2
=
new
TGraphErrors
(
n2
,
x2
,
y2
,
ex2
,
ey2
);
gr2
->SetMarkerColor(
kRed
);
gr2
->SetMarkerStyle(20);
gr2
->Fit(
"pol5"
,
"q"
);
auto
func2
= (
TF1
*)
gr2
->GetListOfFunctions()->FindObject(
"pol5"
);
func2
->SetLineColor(
kRed
);
func2
->SetLineStyle(2);
mg->Add(
gr2
);
mg->Draw(
"ap"
);
//force drawing of canvas to generate the fit TPaveStats
c1
->Update();
auto
stats1
= (
TPaveStats
*)
gr1
->GetListOfFunctions()->FindObject(
"stats"
);
auto
stats2
= (
TPaveStats
*)
gr2
->GetListOfFunctions()->FindObject(
"stats"
);
if
(
stats1
&&
stats2
) {
stats1
->SetTextColor(
kBlue
);
stats2
->SetTextColor(
kRed
);
stats1
->SetX1NDC(0.12);
stats1
->SetX2NDC(0.32);
stats1
->SetY1NDC(0.82);
stats2
->SetX1NDC(0.72);
stats2
->SetX2NDC(0.92);
stats2
->SetY1NDC(0.75);
c1
->Modified();
}
}
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
Double_t
double Double_t
Definition
RtypesCore.h:59
kRed
@ kRed
Definition
Rtypes.h:66
kBlue
@ kBlue
Definition
Rtypes.h:66
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
x2
Option_t Option_t TPoint TPoint const char x2
Definition
TGWin32VirtualXProxy.cxx:70
y2
Option_t Option_t TPoint TPoint const char y2
Definition
TGWin32VirtualXProxy.cxx:70
gStyle
R__EXTERN TStyle * gStyle
Definition
TStyle.h:436
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF1
1-Dim function class
Definition
TF1.h:233
TGraphErrors
A TGraphErrors is a TGraph with error bars.
Definition
TGraphErrors.h:26
TMultiGraph
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition
TMultiGraph.h:34
TPaveStats
The histogram statistics painter class.
Definition
TPaveStats.h:18
TStyle::SetOptFit
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
Definition
TStyle.cxx:1593
c1
return c1
Definition
legend1.C:41
Author
Rene Brun
Definition in file
multigraph.C
.
tutorials
graphs
multigraph.C
ROOT tags/6-34-04 - Reference Guide Generated on Wed Mar 26 2025 04:46:35 (GVA Time) using Doxygen 1.10.0