Hi Kevin, You may get some inspiration from the example below. I strongly suggest you go through the Root tutorials where several examples of this kind are given. Rene Brun { gROOT->Reset(); TCanvas *c1 = new TCanvas("c1","begin with pads", 700, 550); //by default, pad range is in [0,1] TLatex *tInfo = new TLatex(); tInfo->DrawLatex(.5, .95, "Info"); TPad pMain ("pmain", "main pad", 0,0,1,.90); pMain->Draw(); pMain->cd(); pMain->Divide(2,2); pMain->cd(1); TH1F *h1 = new TH1F("h1","random",100,-4,4); h1->FillRandom("gaus",1000); h1->SetStats(0); h1->Draw(); TLatex *t1 = new TLatex(); t1->SetNDC(); //we want to draw this object in the Normalized system [0,1] t1->DrawLatex(.01, .01, "text in question"); //create a pave with some annotations TPaveText *pave = new TPaveText(.6,.7,.95,.95,"brNDC"); pave->SetTextAlign(12); TText *text = pave->AddText("histo info"); text->SetTextFont(72); text->SetTextAlign(22); char temp[20]; sprintf(temp,"mean= %g",h1->GetMean()); pave->AddText(temp); sprintf(temp,"rms = %g",h1->GetRMS()); pave->AddText(temp); pave->Draw(); } On Fri, 7 Jul 2000, Kevin M. Rhodes wrote: > Hello all. > > I've been working on a macro to do a crude visual analysis of sets of > histograms, and I've finally found myself to be stuck. The problem > consists mostly of formatting the layout of my histograms, so perhaps this > seems trivial. Here's a snippet, with problem in tow: > > TCanvas *canvas = new TCanvas(var1, var2, 700, 550); > TLatex *tInfo = new TLatex(); > tInfo->DrawLatex(.5, .95, "Info"); > TPad pMain ("pmain", "main pad", 0,0,1,.90); > pMain->Draw(); > pMain->cd(); > pMain->Divide(2,2); > pMain->cd(1); > TH1F *h1 = (TH1F*)f1->Get(var3); > h1->Draw(); > h1->Fit("myfunction"); > TLatex *t1 = new TLatex(); > t1->DrawLatex(.01, .95, "text in question"); > > Now, I want the t1 TLatex to position itself between the top of the > histogram and the top of the pad. However, no matter what values I give > to DrawLatex, it puts the text in the bottom left corner of the histogram > (mind you, not in the bottom left corner of the pad). I thought that > maybe pads within pads, or histograms and Latex don't get along, or a > number of other unmentionable things. Also, I know that this can be > done via mouse and editor, but I need to automate this for several > hundred files. Any ideas? > > > Even if there is a way to do that, what I'd really like to do is put my > three lines of text (which are in t1) into the TPaveStats pave. So, is > there any way to add those lines to the pave? Can I delete the > TPaveStats pave, create a new pave, and pass in my text along with, say, > Mean and RMS? > > Any help, as always, is most appreciated. > > Kevin Rhodes > UW-Madison > AMANDA group > > >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:29 MET