How do I set logarithmic scale of TH1 histogram

I have a root file with a collection of root histograms.
The file is result of merge of several files with histograms
and I want to do some manupilation on te histograms and write the result
to a new root file. When I write the TH1 histograms to file I first set the “G” Draw option
but this doesn work. When I view the resulting root file with TBrowser
the scales are still linear.

The code looks somethng like this

TFile *inHistoFile = new TFile(inFileName);
TFile *outHistoFile = new TFile(outFileName);

for (all histograms in file)
          .... make tmpFilename and do
          hist = (TH1F *)inHistoFile->Get(tmpHistoName);



The root macro I use is attached, and the file I try to read can be found here

Does anybody know how to view histograms in TBrowser with logarithmic scales ?
inspect.C (2.32 KB)

1 Like

The log scale is not a property of the histogram but of the pad/canvas where you draw it. Do something like

TCanvas c; c.Setlogy();

1 Like

The problem is that I watch the root file and the histograms
with TBrowser, I dont draw them in a canvas. (or maybe TBorvser does ?)

Is it possible to specify to TBrowser that I want the Y axis to be logarithmic ?

Per Thomas Hille

-Create a browser with
TBrowser b;

-Create a canvas via the TBrowser “File” menu
-Click with the right button in the canvas and select “SetLogy”
-Draw your histogram from the browser


1 Like

Thanks a lot, that worked