Tadeusz Pytlos wrote: > > Hello Rooters, > Is any easy way to place text below xaxis? Something like SetXTitle, > but in the middle. I created histogram with methods > ... > TH1F *h1 = new TH1F("h1","Example",100,3,8); > h1.SetLineWidth(2); > h1->Fill(E); > h1.SetXTitle("E[MeV]"); > h1.SetYTitle("N"); > h1.SetMinimum(1); > h1.Draw(); > ... > and I would like to insert below xaxis in the middle information > about the width of bin of my histogram, for example text: dE=0.1 MeV, > where 0.1 wil be automaticly changed, when I change nbins or range. > I'm not sure if TPaveLabel or TText is the best way to use in this > case, because I want to use this mechanism in many macros without > changing coordinates. > Thanks in advance > Tadeusz Here is an example to add a text centered on X and at the bottom of the pad. Rene Brun //-----------------macro axlabel.C { TCanvas *c1 = new TCanvas("c1"); gROOT->Reset(); TH1F *h1 = new TH1F("h1","Example",100,3,8); h1.SetXTitle("E[MeV]"); h1.SetYTitle("N"); h1.SetMinimum(0); h1.SetMaximum(100); h1.Draw(); c1->Update(); // this forces painting in the pad char label[30]; sprintf(label,"DE=%5.2f MeV",h1->GetXaxis()->GetBinWidth(1)); TText *xlabel = new TText(); xlabel->SetTextAlign(21); Float_t x1 = c1->GetX1(); Float_t x2 = c1->GetX2(); Float_t y1 = c1->GetY1(); Float_t y2 = c1->GetY2(); xlabel->SetTextSize(0.03); xlabel->DrawText(0.5*(x1+x2), y1 + 0.01*(y2-y1), label); }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET