Hello.
In my case, I’d like to add a text line in the stats box as well, but I’m working with a THStack. I display two stats boxes as indicated here in the forth entry (I’m dealing with two histograms):
Then, I tried (h1_firCorrectionf1, h1_firCorrectionf2 are the histograms; st1, st2 are the TPaveStats intances from them):
h1_firCorrectionf1->SetBit(TH1::kNoStats);
st1->AddText("Xpeakf1 "+xf1);
st1->Draw();
gPad->Modified();
but the new line is not drawn in the canvas. It’s added as it can be seen with st1->Print();
TPaveStats X1=1665.800065 Y1=516.185451 X2=2302.800084 Y2=638.540518 FillStyle=1001
Collection name='TList', class='TList', size=5
Text X=0.000000 Y=0.000000 Text=h1_firCorrection_0f1 Font=0 Size=0.036800 Color=0 Align=0
Text X=0.000000 Y=0.000000 Text=Entries = 2736 Font=0 Size=0.000000 Color=0 Align=0
Text X=0.000000 Y=0.000000 Text=Mean = 6.713 Font=0 Size=0.000000 Color=0 Align=0
Text X=0.000000 Y=0.000000 Text=RMS = 208.1 Font=0 Size=0.000000 Color=0 Align=0
Text X=0.000000 Y=0.000000 Text=Xpeakf1 -53 Font=0 Size=0.000000 Color=0 Align=0
I tried as well the following without success:
TList* listf1 = st1->GetListOfLines();
TList* listf2 = st2->GetListOfLines();
TLatex* textf1 = new TLatex(0,0,"Xpeakf1 "+xf1);
TLatex* textf2 = new TLatex(0,0,"Xpeakf2 "+xf2);
listf1->Add(textf1);
listf2->Add(textf2);
st1->Print();
st2->Print();
h1_firCorrectionf1->SetStats(0);
h1_firCorrectionf2->SetStats(0);
st1->Draw();
st2->Draw();
gPad->Modified();
and even though it’s not drawn, the print() shows that the line has been added as well.
Any suggestions?
Thank you!
Daniel