Divide canvas in loop

Hi
I am triyng to divide canvas in the following way. I am using same histogram and histogram style in all each case. But the X-axis size look different in cd(5) from cd(6)-cd(8). I am using ROOT v5.34/36.
Please have a look at the attached output plot.
Can anyone please tell me what could be the reason and how to fix it!?

Thanks in advance,

With Regards,
Arghya

//===================================
    TCanvas *c1 = new TCanvas("c1");
    c1->SetLeftMargin(0.2);
    c1->SetBottomMargin(0.2);
    c1->Divide(4,2,0,0);
    int k = 0;
    
    for (int pp = 0; pp < 8; pp++) {
        k++;
        c1->cd(k);
        gPad->Update();
        graph_style(histo_Vz[pp], 2, 2, 1, 1, 2, 2);
        //histo_Vz[pp]->Rebin();
        histo_Vz[pp]->Draw("l");
    }

//========= Drawing style ========================

void graph_style(TH1F *graphname, int marker_style_no , int marker_color_no, double marker_size_no, int line_style_no, int line_color_no, double line_width_no)
{
    graphname->SetMarkerStyle(marker_style_no);
    graphname->SetMarkerColor(marker_color_no);
    graphname->SetMarkerSize(marker_size_no);
    
    graphname->SetLineStyle(line_style_no);
    graphname->SetLineColor(line_color_no);
    graphname->SetLineWidth(line_width_no);
    
    //axis properties
    graphname->GetXaxis()->CenterTitle(true);
    graphname->GetXaxis()->SetTitleSize(0.1);
    graphname->GetXaxis()->SetNdivisions(505);
    graphname->GetXaxis()->SetLabelFont(42);
    graphname->GetXaxis()->SetLabelSize(0.12);
    graphname->GetXaxis()->SetTitleOffset(1.16);
    graphname->GetXaxis()->SetTickLength(0.05);
    
    graphname->GetYaxis()->CenterTitle(true);
    graphname->GetYaxis()->SetTitleSize(0.1);
    graphname->GetYaxis()->SetNdivisions(505);
    graphname->GetYaxis()->SetLabelFont(42);
    graphname->GetYaxis()->SetLabelSize(0.12);
    graphname->GetYaxis()->SetTitleOffset(1.16);
    graphname->GetYaxis()->SetTickLength(0.05);
    
}

//===================================

${ROOTSYS}/tutorials/graphics/canvas2.C

Hi Wile
Thanks a lot!

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