Re: TH->Draw() Draw options question.

From: Anton Fokin (kosu_fokin@garbo.lucas.lu.se)
Date: Wed Mar 17 1999 - 19:07:52 MET


Hi Rene,

I think I got it. But ... but ... Isn't it in the line of OOP that every
object knows how to draw itself? Well, anyway my problem is that I have an
array of histograms, let's say TH *hist[2], then I define TH1F *H1F = new
TH1F() and TH2F *H2F = new TH2F() and finally hist[0]=H1F; hist[1]=H2F;
Then somewhere in my program I write

for(int i=0;i<2;i++) {
  hist[i]->Draw();
}

Of course I want this histos to be drawn with the draw options I defined
before. I do not want to hold a separate list of draw options, moreover
even if I have such a list  I  would not know sometimes what draw options
should I use since all I know about a histo is a general pointer of TH
type.

Now I also understand why can't I use the built in "draw option pad" which
appears when you click on a histogram. I am updating histograms
dynamically, so if I change the draw option once using this pad, the next
time I update my histo I lose this info. Is it any reason to not store this
info in the object itself? Of course I can derive my own TH1 and TH2 with
such properties but wouldn't it be better to include it into the original
package?

BTW, it also seems that I can not define LOGY (and other options) for a
histogram, but rather for a pad. Is it true?

i.e. if I do

c1->cd();
H1->Draw();

// here I change to LOGY using "on click option pad"

....

c1->cd();
H2->Draw();

I will get H2 drawn also in LOGY ....

Regards,

Dr. Anton Fokin

Division of Cosmic and Subatomic Physics
Lund University
Sweden

----------
> From: Rene Brun <Rene.Brun@cern.ch>
> To: Anton Fokin <kosu_fokin@garbo.lucas.lu.se>
> Cc: roottalk@hpsalo.cern.ch
> Subject: Re: TH->Draw() Draw options question.
> Date:  den 17 March 1999 18:40
> 
> Anton,
> TObject::SetDrawOption will only be effective on an object already in
> the pad.
> The specified option is not stored with the object itself, but in the
> option
> attribute when the object is added in the pad list.
> You must have the sequence
>   hist->Draw("some or no option)
>   hist->SetDrawOption(another option)
> 
> 
> Rene Brun
> 
> 
> Anton Fokin wrote:
> > 
> > Hi Rene,
> > 
> > if I write
> > 
> > hist->SetDrawOption("COLZ");
> > hist->Draw();
> > 
> > it still draws with "" option. Moreover if I write
> > 
> > hist->SetDrawOption("COLZ");
> > printf("Draw option - %s\n", hist->GetDrawOption());
> > 
> > it doesn't print any "COLZ" at all, but just "". Could you explain how
it
> > works or should work in reality?
> > 
> > Regards,
> > 
> > Dr. Anton Fokin
> > 
> > Division of Cosmic and Subatomic Physics
> > Lund University
> > Sweden
> > 
> > ----------
> > > From: Rene Brun <Rene.Brun@cern.ch>
> > > To: Anton Fokin <kosu_fokin@garbo.lucas.lu.se>
> > > Cc: roottalk@hpsalo.cern.ch
> > > Subject: Re: TH->Draw() Draw options question.
> > > Date:  den 17 March 1999 16:30
> > >
> > > Anton Fokin wrote:
> > > >
> > > > Hi there,
> > > >
> > > > I couldn't find if it's possible to set draw options for a histo
> > somewhere
> > > > outside TH.Draw()? I would like to have different options set for
every
> > > > histo I have and let a histo draw itself with a corresponding draw
> > option
> > > > whenever I use a generall call to TH.Draw();
> > > >
> > > > Regards,
> > > >
> > > > Dr. Anton Fokin
> > > >
> > > > Division of Cosmic and Subatomic Physics
> > > > Lund University
> > > > Sweden
> > >
> > > Hi Anton,
> > > Yes, this is possible. Via TObject::SetDrawOption(const char* option)
> > > You can do:
> > >   hist->Draw(some option);
> > >   hist->SetDrawOption(another option) as many times as you want.
> > > SetDrawOption is called by the histogram DrawPanel widget.
> > >
> > > Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET