Two Histos above each other with same x-axis

Hi ROOTers,

suppose I have two histograms which both have the same x-range. I’d like to draw them one above the other vertically (not superimposed, just the second histo right below the first) such that the lower x-axis of the top histogram is the upper x-axis of the bottom histogram, i.e., so that they both share a common axis. Labels on the bottom x-axis of the bottom histo would be enough.

Is there something implemented to faciliate this, or do I have to fiddle with the margins and pads until I have it (which probably would work as well, just asking)

Thanks!

Cheers,
Rafi :slight_smile:

possible example

Rene

void h2() { TCanvas *c1 = new TCanvas("c1","test 2 histos",800,1000); c1->Divide(1,2,0,0); TH1F *hist1 = new TH1F("hist1","hist1",100,-3,3); hist1->FillRandom("gaus",1000); c1->cd(1); hist1->Draw(); gPad->SetGridx(); c1->cd(2); gPad->SetTickx(); gPad->SetGridx(); TH1F *hist2 = new TH1F("hist2","hist2;x title",100,-3,3); hist2->FillRandom("gaus",2000); hist2->Draw(); }

I just /knew/ it, there is something implemented to faciliate this… thank you, Rene!

Cheers,
Rafi :smiley:

Could you come with something simpler?

Rene

Haha, no, for sure not! :slight_smile: That’s what I mean, your way is really simple and exactly what I was looking for! :slight_smile: Before, I had tried fudging various margins here and there but it never worked out so nicely as with the simple Divide(n,n,0,0).

Cheers,
Rafi :slight_smile: