Setting a histogram x axis rage for a splitted histogram?

Hi folks,

I have been trying to draw two histograms stacked on top of each other by splitting the parent histogram into two sets of axis ranges. I have divided the canvas. However, I am not able to set the x-axis ranges for both separately ? When I use

c1->cd(1)
h1->GetXaxis()->SetRangeUser(0, 0.5)
c1->cd(2)
h1->GetXaxis()->SetRangeUser(0.5, 1)

It changes the X-axis for both the histogram ranges. I am trying to set the range 0 to 0.5 for above and 0.5 to 1 for below.

Thanks in advance!

Well, you call SetRangeUser() twice on the same histogram, so this is not going to work. But I’m sure @couet will tell you how to do it properly

1 Like

Oh I see, thanks for highlighting the issue.

c1->cd(1);
h1->Draw();
h1->GetXaxis()->SetRangeUser(0, 0.5);
c1->cd(2);
h1->DrawCopy()->GetXaxis()->SetRangeUser(0.5, 1)

should work I guess…

1 Like

Yeah, it works like a charm ! Thanks a lot.

1 Like