Offsets when plotting data on logarithmic X axis

I find that when I try to plot a histogram using SetLogx() and
SetLimits() for the axis, the actual data are plotted with an offset
equal to the Xmin value I give in the SetLimits() call. E.g. in the
following code I set points at .00001 and .00004, but if I set Xmin
to .00001 they are plotted at .00002 and .00005, or with Xmin set to
0.00005, at .00006 and .00009. This happens with 5.13/04e and also
when I just checked a colleagues installation of 5.17. Plot is at
brunel.ac.uk/~eesridr/logError.ps if I screw up the attachment…

Am I doing something wrong, or is there a bug that’s never been noticed?

#############
from ROOT import gROOT, gStyle, TH1F, TCanvas, TPad, TPaveStats, TLine

a=TH1F(“Test”,“Test”,1000,0.,.001)
a.Fill(0.00001)
a.Fill(0.00004)

c2=TCanvas(“c2”,“c2”,800,800)
c2.Divide(2,2)
c2.cd(1)
a.SetTitle(“Linear Axis”)
a.Draw()

b=a.Clone(“b”)
c2.cd(2)
p=c2.GetPad(2)
p.SetLogx()
b.SetTitle(“Default Log Axis”)
b.Draw()
c=a.Clone(“c”)
c2.cd(3)
p2=c2.GetPad(3)
p2.SetLogx()
c.GetXaxis().SetLimits(.00001,.001)
c.SetTitle(“Log Axis, min=0.00001”)
c.Draw()
d=a.Clone(“d”)
c2.cd(4)
p3=c2.GetPad(4)
p3.SetLogx()
d.GetXaxis().SetLimits(.00005,.001)
d.SetTitle(“Log Axis, min=0.00005”)
d.Draw()
c2.Update()
c2.Print(“logError.ps”)
logError.ps (23.6 KB)

Log scales is not the reason one you get this. It is the same in linear scale. The following macro shows it:

{
   TGaxis::SetMaxDigits(2);
   TH1F *a = new TH1F("Test","Test",1000,0.000001,.00006);
   a->Fill(0.00001);   
   a->Fill(0.00002);
   a->Fill(0.00003);
   a->Fill(0.00004);
   a->Fill(0.00005);

   TCanvas *c2 = new TCanvas("c2","c2",600,600);
   c2->Divide(1,2);
   c2->cd(1);
   a->Draw();

   TH1 *c = a.Clone("c");
   c2->cd(2);
   c->GetXaxis()->SetLimits(.00001,.00006); 
   c->GetXaxis()->SetAxisColor(2);
   c->Draw();  
}

As you can see, Setlimits changes the limits of the histogram axis but not the histogram’s bins’ position. If you want to do some kind of zooming you should use SetRange.