TStyle as an object attribute

Hi,

I use ROOT in compiled code (no CINT) and I wonder if it is possible to attach a TStyle to a particular object. I create TH1 and TH2 objects and would like for example to set log scale to TH1 histograms only. It seem that the style is very global and that it is not possible. Am I right?

Philippe

Do:

mystyle->cd(); myhist->UseCurrentStyle();
Rene

The style properties are apparently not attached to myhist… Basically, I have saved histograms in a ROOT file, suppose bluehist and redhist. In a TBrowser, I would likle bluehist to pop up with blue bars when clicked while red bars are used when I click redhist. Since TStyle is a canvas/pad thing, I guess this is not possible?

TStyle IS NOT a canvas/pad thing.
Histograms have their own attributes (colors, text size, markers, etc). These attributes can be set on individual histograms:
-by calling myhist->Setxxxx functions
-by default histogram properties inherit the properties set in the current style when creating the histogram.
-in case of histograms saved to a file, you can force these histograms (or other objects) to take the attributes of the current style at the time when the histogram is read from a file. To use this case, you should call gROOT->ForceStyle() before reading your histograms.

Note that things like a log scale are not attributes of an histogram, they are attributes of the pad where you draw your histograms. It does not make sense to draw a histogram in linear scale, then another one on top in log scale.

Rene