Maximum label size for which SetStripDecimals works?

Dear experts,

I just ran across the following. When drawing a TGraph, if the strings on the vertical axis become too long (looks like more than eight characters, including the dot) then setting TStyle::SetStripDecimals(1) no longer works.

Please see the below piece of code which can produce two output figures (cases oops' andnot oops’), both attached.

from ROOT import gStyle
from ROOT import TCanvas
from ROOT import TGraph

if __name__ == "__main__":

    # Do not strip decimal zeros off the axis labels.
    gStyle.SetStripDecimals(False)

    gStyle.SetPadLeftMargin(.15)
    gStyle.SetPadBottomMargin(.12)

    graph_freq = TGraph()

    # Use this to toggle the problem.
    oops = True

    if oops:
        graph_freq.SetPoint(0, 933., 40078879.) # <-- y-value more than 7 characters
        graph_freq.SetPoint(1, 934., 40078966.) # <-- y-value more than 7 characters
    else:
        graph_freq.SetPoint(0, 933., 4007887.) # <-- y-value only 7 characters
        graph_freq.SetPoint(1, 934., 4007896.) # <-- y-value only 7 characters

    canvas = TCanvas("canvas")
    graph_freq.Draw("A*")
    canvas.Print("test_strip_decimals.eps")

    # Done

The same thing happens in v5.18/00 and the current SVN head, in my case on a MacBook and from PyROOT but I don’t think those are relevant.

Was this a choice? It seems a bit arbitrary. Can I work around this?

Cheers,
Jeroen
test_strip_decimals_not_oops.pdf (3.3 KB)
test_strip_decimals_oops.pdf (3.29 KB)

When gStyle.SetStripDecimals() is TRUE (which is the default) the trailing zeros after the decimal dot are removed. When gStyle.SetStripDecimals() is FALSE the trailing zeros are not removed. With your macro I see that gStyle.SetStripDecimals(kFALSE) has no effect. The following macro is the simplified C++ version of your example. Notice that I have added a commented line. If your remove the comment then gStyle.SetStripDecimals(kFALSE) has some effect again. I will look at this.

{
   gStyle.SetStripDecimals(kFALSE);  
   gStyle.SetPadLeftMargin(.15);
   gStyle.SetPadBottomMargin(.12);
//   TGaxis::SetMaxDigits(6);  

   TGraph graph_freq;

   graph_freq.SetPoint(0, 933., 40078879.); 
   graph_freq.SetPoint(1, 934., 40078966.); 

   graph_freq.Draw("A*");
}

This in now fixed in the SVN trunk. gStyle.SetStripDecimals(kFALSE) now works with the following macro:

  {
     gStyle.SetStripDecimals(kFALSE);
     gStyle.SetPadLeftMargin(.15);
     TGraph graph_freq;
     graph_freq.SetPoint(0, 933., 40078879.);
     graph_freq.SetPoint(1, 934., 40078966.);
     graph_freq.Draw("A*");
  }

Thanks for reporting this problem.

Nice, thanks for the quick fix Olivier!

Cheers,
Jeroen