Logo ROOT  
Reference Guide
No Matches
statsEditing.C File Reference

Detailed Description

View in nbviewer Open in SWAN
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);
// Retrieve the stat box
TPaveStats *ps = (TPaveStats*)se->GetPrimitive("stats");
TList *listOfLines = ps->GetListOfLines();
// Remove the RMS line
TText *tconst = ps->GetLineWith("RMS");
// 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);
// the following line is needed to avoid that the automatic redrawing of stats
return se;
#define h(i)
Definition RSha256.hxx:106
@ kRed
Definition Rtypes.h:66
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:46
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:47
The Canvas class.
Definition TCanvas.h:23
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2483
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:578
To draw Mathematical Formula.
Definition TLatex.h:18
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:822
void Modified(Bool_t flag=true) override
Definition TPad.h:420
TObject * GetPrimitive(const char *name) const override
Get primitive.
Definition TPad.cxx:2887
The histogram statistics painter class.
Definition TPaveStats.h:18
virtual TList * GetListOfLines() const
Definition TPaveText.h:48
virtual TText * GetLineWith(const char *text) const
Get Pointer to first containing string text in this pavetext.
virtual void SetName(const char *name="")
Definition TPave.h:75
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:1636
Base class for several text objects.
Definition TText.h:22
Olivier Couet

Definition in file statsEditing.C.