TGaxis and SetMaxDigits

Hi Everyone,

I just stumbled about a strange artefact while working with TGaxis. When I plot a new axis, the exponent is wrong, if i do SetMaxDigits. I have a minimal Example, showing the different exponents with and without the line " ROOT.TGaxis.SetMaxDigits(1)". Any ideas?

Cheers,

Daniel

import ROOT

def main():
    xMin = -5
    xMax = 5
    hist = ROOT.TH1F("hist","hist",100,xMin,xMax)
    gaus = ROOT.TF1("g","gaus",xMin,xMax)
    gaus.SetParameters(1,2,3)
    hist.FillRandom("g")
    
    c = ROOT.TCanvas()
    frameHist = c.DrawFrame(xMin,0,xMax,100,"ASDF")
    
    #Commenting this in makes problems!!!
    #ROOT.TGaxis.SetMaxDigits(1)
     
    axis = frameHist.GetYaxis()
    axis.SetLabelOffset(999)
    axis.SetTickLength(0)
     
    uYMin = ROOT.gPad.GetUymin()
    uYMax = ROOT.gPad.GetUymax()
    uXMin = ROOT.gPad.GetUxmin()
    uXMax = ROOT.gPad.GetUxmin()
    axisFun = ROOT.TF1("axisFun","-x",0,100);
    newAxis = ROOT.TGaxis(  uXMin,
                            uYMin,
                            uXMax,
                            uYMax,
                            "axisFun",
                            )
    newAxis.Draw("Same")    
    hist.Draw("Samehist")
     
    c.Update()
    raw_input()

 
if __name__ == "__main__":
    main()

I am not sure SetMaxDigits works with Axis Function.
I made a bug report with this:
sft.its.cern.ch/jira/browse/ROOT-7442

Thanks

This equivalent small C macro reproduces the effect:

{
    TCanvas *c = new TCanvas();
    c->DrawFrame(-5,0,5,100,"ASDF");

    //Un-Commenting this in makes problems!!!
    //TGaxis::SetMaxDigits(0);

    TF1 *axisFun = new TF1("axisFun","-x",0,100);
    TGaxis *newAxis = new TGaxis(  0.,0.,0.,100,"axisFun");
    newAxis->Draw("");
}

I’m sorry, I just saw it. Thank you. I tried it, but there was an error in the code. I want to use it this way in graph,
image

but it is not allowed. Could you please tell me how to achieve this goal?

For a “g1” graph, try (in ROOT 6):

g1->GetHistogram()->GetYaxis()->SetMaxDigits(1);

I can’t use root6 in my current environment.
I use root 5.34,an old version.
But I really appreciate your help!

For the older versions SetMaxDigits is a global setting for all axis:

TGaxis::SetMaxDigits(1);