How can I change the parameters in the StatBox in a histogram? I need non-standard values, e.g. Median. I have a way to calculat this, but how can I now put this name (median) & its value in the StatBox?
Jan
[code]
void mystats() {
TCanvas *c1 = new TCanvas;
TH1F *h = new TH1F(“h”,“test”,100,-3,3);
h->FillRandom(“gaus”,3000);
gStyle->SetOptStat();
h->Draw();
c1->Update();
TPaveStats ps = (TPaveStats)c1->GetPrimitive(“stats”);
ps->SetName(“mystats”);
TList *list = ps->GetListOfLines();
TText *tconst = ps->GetLineWith(“RMS”);
list->Remove(tconst);
TLatex *myt = new TLatex(0,0,“test = 10”);
list->Add(myt);
h->SetStats(0);
c1->Modified();
}[/code]
And for this entry to match the stat format (font, size, color, …):
{
gStyle->SetOptStat("nemroui") ;
TCanvas *c1 = new TCanvas();
TH1F *h = new TH1F("h","test",100,-3,3);
h->FillRandom("gaus",3000);
h->Draw();
c1->Update();
TPaveStats *ps = (TPaveStats*)c1->GetPrimitive("stats");
ps->SetName("mystats");
TList *list = ps->GetListOfLines();
TText *tconst = ps->GetLineWith(gEnv->GetValue("Hist.Stats.RMS","issue"));
TText *tconst_ = (TText*)tconst->Clone("mytconst");
tconst_->SetTitle("Median = ...");
Int_t idx=list->IndexOf(tconst);
list->Remove(tconst);
list->AddAt(tconst_,idx);
h->SetStats(0);
c1->Modified();
}
Cheers,
Z