[ROOT] Suggestion about TH1

From: Sebastien Greder (greder@in2p3.fr)
Date: Fri Apr 19 2002 - 17:29:57 MEST


Hello Rooters,

I was just wondering about TH1 objects ; usually when I want to plot
an/several histo(s) and/or save it(them),the different steps look like:

- create my histo
- fill it
- give some attributes settings (color, marker style and so on)
- draw or histo->Write()

If I want my histo(s) to have a log scale (x or y), I have to act on the
corresponding pad through the SetLogX method. So this operation can only
be done once the histo has been drawn or saved.

Since I'm a lazy guy, I usually write some macros to plot/save several
histos like :

void Plot_ps(TH1* hist1, Char_t* title = "", Char_t* option = "", 
	  Bool_t logy = 0, Bool_t logx = 0, Bool_t fit = 0,
	  Int_t stati = 111111, Bool_t wait = 0, etc .....)
{
  TCanvas *c1 = (TCanvas*)gROOT->FindObject("c1");
  if (c1) {c1->Clear();} 
  else {
    style();
    c1 = (TCanvas*)gROOT->FindObject("c1");
  }
  
  TPad* pad1 = new TPad("pad1","pad",0.03,0.03,0.98,0.98);
  pad1->Draw();
  if (logy) pad1->SetLogy(); if (logx) pad1->SetLogx();

  pad1->cd();
  hist1->SetFillColor(5);
  hist1->SetEverythingIwantToDoToHaveANiceHisto();
 
  if (fit) hist1->Fit("gaus");
  hist1->GetXaxis()->SetTitleSize(0.05);
  hist1->Draw(option); 

// l'histo est memorise
  c1->Update();  
}

but it's not always a convenient situation.
In fact there are a lot of things that can be set in before "validating"
a histo (about ~40 "Set..." methods dealing with content,axis
range,colors, etc ...) so why not SetLogX/Y ?
It should be nice to have this possibility in TH1 or in TAxis (so that a
histo->GetXAxis()->SetLogX() could be done).

Or did I miss something and this operation  is already available ?? 

Cheers,

sebastien.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:50 MET