How to set axes in log scale for a histogram without calling

Hi, Rooters,

I have some histograms which have been filled in a script without opening TCanvas and TPad.
So, examples like this don’t help me much, root.cern.ch/root/html/tutorial … les.C.html.

Although I’ve tried a lot, still stuck.
Do your guys have any comments to fix it ?
Thanks !

Best,
Junhui

My code is something like this.

        TH1F hist // histogram definition here.
        gPad->SetLogy();
        for(int i=0;i<npix;++i){
           hist->Fill(outArray[i]);
        }
        gPad->Modified();
        gPad->Update(); 

TPad::SetLog[xyz] methods do NOT influence the histogram itself. They just modify the way the histogram is drawn in the current pad.
Search for “variable bin size” in the TH1 class description and see the “ROOT User’s Guide -> Histograms -> Creating Histograms -> Constant or Variable Bin Width” subsection.

The log sale is not an attribute of the histogram, but and attribute of the Pad. If you save the canvas instead of the histogram then the log attribute will be kept.