Re: TH->Draw() Draw options question.
Rene Brun (Rene.Brun@cern.ch)
Wed, 17 Mar 1999 18:29:12 +0000
Anton Fokin wrote:
>
> 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?
>
Hi Anton,
In case of TH1 objects, you have a data member
TString fOption;
with the corresponding setter/getter
Option_t *GetOption()
void SetOption(Option_t *option)
You can do what you request above. This is not necessarily a good idea.
You may want to draw the same histogram with different options in
different pads.
> 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 ....
>
Yes, and it should be like that. The log scale is a property of the pad,
not of the object in the pad.
If you set a LOGY scale in a pad, all objects drawn in the pad must
use the log scale. There is no point in drawing hist1 in LOGY
and hist2 in LIN scale.
Rene Brun