Sometimes the axis range can not be defined by users?

i want to change the X axis range using the code below:

hist2->GetXaxis()->SetRangeUser(1.e-2,20000.);

but it does not work well,like the figure below:


why the code does not work?


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24/04
Platform: Ubuntu 20.04
Compiler: GCC 9.3.0


Try this

It works for me wiith this small example:

void rangeuser(){
   auto C = new TCanvas();
   auto h = new TH1F("h","h",100,1,1000000);
   C->SetLogx();
   h->GetXaxis()->SetRangeUser(1,1000);
   h->Draw();
}

I think the issue is that they want the plot to go beyond the maximum x bin of hist2 (20000 vs 20). SetRangeUser does not “extend” the x-axis beyond the histogram bins, but SetLimits works.

1 Like

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