Incorrect Axis Placement under automatic binning

I ran into an issue where the plot created by a TTree::Draw() command had axes and labels placed at incorrect locations, as shown in the picture below, created using ROOT6.06/02.

This occurs when the values in the tree are very close together. For example, the above plot was made with the following commands.

TTree t("t","t");
double x;
t.Branch("x",&x,"x/D");

x = 2;
t.Fill();
x = 2 - 5e-16;
t.Fill();

t.Draw("x");

I run into this occasionally when all values in the tree should be numerically equal, but due to floating point rounding errors, they are not. How do I avoid this issue?

I see this problem too. I am checking.

This is a precision issue. The macro you posted generates an histogram with very close X axis limits, beyond the precision level the graphics can handle. You can reproduce it with :

root [0] TH1D *h = new TH1D("h","h",100,2- 6e-16,2+ 6e-16);
root [1] h->Draw()

I would suggest the following workaround:

{
   TTree t("t","t");
   double x;
   t.Branch("x",&x,"x/D");
   TH1D *h = new TH1D("h","h",100,2- 5e-3,2+ 5e-3);
   x = 2;
   t.Fill();
   x = 2 - 5e-16;
   t.Fill();
   t.Draw("x>>h");
}

Ah, interesting. Thank you for investigating it, and for the workaround. Is there somewhere where I should make a bug report as well?

I am not sure it is a bug. As the we reach the precision limit it might be better to let it like that.