Precision of axis labels

Consider this example:

int labelnumbers()
{
  TH1F * h = new TH1F("h", "h", 2, 0.0, 2.0);
  h -> GetYaxis() -> SetRangeUser(0.6, 1.4);
  h -> GetYaxis() -> SetNdivisions(503);
  TCanvas * c = new TCanvas;                                                                                                                                                   
  h -> Draw();
  return 0;
}

The output is:

Not only the middle labels carry an unneeded level of precision, the precision is also different from label to label. How to define the precision for axis labels?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,
try to use
TAxis::SetDecimals() and TAttAxis::SetMaxDigits(), using SetMaxDigits(2) maybe can be a good choice for you.

Cheers,
Stefano

1 Like

I would rather use at least SetMaxDigits(3) combined with SetDecimals. Seems to me, given the small range on the Y Axis, SetMaxDisgits(2) produces a to strong rounding.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.