ROOT
v6-20
Reference Guide
statsEditing.C File Reference
Tutorials
»
Histograms tutorials
Detailed Description
Edit statistics box.
This example shows:
how to remove a stat element from the stat box
how to add a new one
TCanvas
*statsEditing() {
// Create and plot a test histogram with stats
TCanvas
*se =
new
TCanvas
;
TH1F
*
h
=
new
TH1F
(
"h"
,
"test"
,100,-3,3);
h
->FillRandom(
"gaus"
,3000);
gStyle
->
SetOptStat
();
h
->Draw();
se->
Update
();
// Retrieve the stat box
TPaveStats
*
ps
= (
TPaveStats
*)se->
GetPrimitive
(
"stats"
);
ps
->SetName(
"mystats"
);
TList
*listOfLines =
ps
->GetListOfLines();
// Remove the RMS line
TText
*tconst =
ps
->GetLineWith(
"RMS"
);
listOfLines->
Remove
(tconst);
// Add a new line in the stat box.
// Note that "=" is a control character
TLatex
*myt =
new
TLatex
(0,0,
"Test = 10"
);
myt ->
SetTextFont
(42);
myt ->
SetTextSize
(0.04);
myt ->
SetTextColor
(
kRed
);
listOfLines->
Add
(myt);
// the following line is needed to avoid that the automatic redrawing of stats
h
->SetStats(0);
se->
Modified
();
return
se;
}
h
#define h(i)
Definition:
RSha256.hxx:106
kRed
@ kRed
Definition:
Rtypes.h:64
gStyle
R__EXTERN TStyle * gStyle
Definition:
TStyle.h:407
TAttText::SetTextColor
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition:
TAttText.h:43
TAttText::SetTextFont
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition:
TAttText.h:45
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition:
TAttText.h:46
TCanvas
The Canvas class.
Definition:
TCanvas.h:31
TCanvas::Update
virtual void Update()
Update canvas pad buffers.
Definition:
TCanvas.cxx:2339
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition:
TH1.h:571
TLatex
To draw Mathematical Formula.
Definition:
TLatex.h:18
TList
A doubly linked list.
Definition:
TList.h:44
TList::Add
virtual void Add(TObject *obj)
Definition:
TList.h:87
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition:
TList.cxx:819
TPad::Modified
void Modified(Bool_t flag=1)
Definition:
TPad.h:417
TPad::GetPrimitive
virtual TObject * GetPrimitive(const char *name) const
Get primitive.
Definition:
TPad.cxx:2865
TPaveStats
The histogram statistics painter class.
Definition:
TPaveStats.h:18
TStyle::SetOptStat
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition:
TStyle.cxx:1450
TText
Base class for several text objects.
Definition:
TText.h:23
TGeant4Unit::ps
static constexpr double ps
Definition:
TGeant4SystemOfUnits.h:165
Author
Olivier Couet
Definition in file
statsEditing.C
.
tutorials
hist
statsEditing.C
ROOT v6-20 - Reference Guide Generated on Fri Apr 1 2022 00:24:42 (GVA Time) using Doxygen 1.9.4