Annoying automatic Y range with log scale

Hello,

I found an odd behavior when drawing a graph on a log scale. Here is simplek example:

void logy()
{
   TGraph * gr = new TGraph(10);
   for(int i = 0;i<5;i++){
      gr->SetPoint(i,i,TMath::Exp(-10.0*i));
   }
   for(int i = 5;i<10;i++){
      gr->SetPoint(i,i,0);
   }
   TCanvas * c = new TCanvas();
   gPad->SetLogy(true);
   gr->Draw("apl");
}

I run it with

Why wouldn’t it change the scale to show all the graph points that are not zero by default?

If I change the exponent to -1 instead of -10 it works as desired. Also it works if the first loop goes all the way to 10 without any points with y=0, ie,

void logy()
{
   TGraph * gr = new TGraph(10);
   for(int i = 0;i<10;i++){
      gr->SetPoint(i,i,TMath::Exp(-10.0*i));
   }
   TCanvas * c = new TCanvas();
   gPad->SetLogy(true);
   gr->Draw("apl");
}

I guess this is a corner case but it would be really nice if it just worked the ideal way.

I agree. This looks weird.
Looking at it.

I think I found the fix. I need to investigate more to be sure there is no bad side effects. I’ll let you know when it will be committed (in master).

Now fixed in master:
github.com/root-mirror/root/com … ee6ddc819c

Thanks for reporting it.

Thanks!