[cernRoot] How make a beautiful graph by CernRoot?

//    just for myself, may be it is useless for you)
    double xmin = 0.15, xmax = 1.65, ymin = .0, ymax = .59;
    double x[3] = {1./8., 4./8., 7./8.};
    double y[6] = {1./17., 4./17., 7./17., 10./17., 13./17., 16./17.};
    for(int i = 0; i < 3; i ++) x[i] += 0.2/8.;
    for(int i = 0; i < 6; i ++) y[i] += 0.2/17.;
    TCanvas * cc = new TCanvas("b39_b","b39_b",0,0,8*50,17*50);
    TPad * pad0 = new TPad("","",0,0,1,1);
    pad0->Draw();
    pad0->cd();
    TPad ** pad = new TPad * [ndeltaEta + 1];
    for(int i = 0; i < ndeltaEta+1; i ++)
    {
        pad0->cd();
        pad[i] = new TPad("","",x[i%2],y[6-2-i/2],x[i%2+1],y[6-1-i/2]);
        pad[i]->Draw();
    }
    TH2D * haxis = new TH2D("","",100,xmin,xmax,100,ymin,ymax);
    haxis->SetStats(0);
    haxis->GetXaxis()->SetNdivisions(505);
    haxis->GetYaxis()->SetNdivisions(508);
    for(int i = 0; i < ndeltaEta+1; i ++)
    {
        pad[i]->cd();
        pad[i]->SetMargin(0,0,0,0);
        pad[i]->SetTicks(1,1);
        pad[i]->SetGrid(0,1);
//        pad[i]->SetLogy();
        haxis->Draw();
    }
    const int color[6] = {kBlack,kRed,kBlue,kGreen,kYellow+2,kPink+3};
    const int markerStyle[6] = {20,21,22,23,33,34};
    for(ideltaeta = 0; ideltaeta < ndeltaEta; ideltaeta ++)
    {
        pad[ideltaeta]->cd();
        for(icen = 0; icen < ncendeg; icen ++)
        {
            gr[ideltaeta][icen]->SetMarkerColor(color[icen]);
            gr[ideltaeta][icen]->SetMarkerStyle(markerStyle[icen]);
            gr[ideltaeta][icen]->Draw("p");
        }//icen
    }//ideltaeta
    pad0->cd();
    TGaxis ** axisx = new TGaxis * [4];
    TGaxis ** axisy = new TGaxis * [10];
    for(int i = 0; i < 2; i ++)
    {
        axisx[i] = new TGaxis(x[i],y[0],x[i+1],y[0],xmin,xmax,505,"");
        axisx[i+2] = new TGaxis(x[i],y[5],x[i+1],y[5],xmin,xmax,505,"-");
        axisx[i]->SetLabelSize(0.05);
        axisx[i]->SetLabelOffset(-0.015);
        axisx[i+2]->SetLabelSize(0.05);
        axisx[i]->Draw();
        axisx[i+2]->Draw();
    }
    for(int i = 0; i < 5; i ++)
    {
        axisy[i] = new TGaxis(x[0],y[i],x[0],y[i+1],ymin,ymax,105,"");
        axisy[i+5] = new TGaxis(x[2],y[i],x[2],y[i+1],ymin,ymax,105,"+L");
        axisy[i]->SetLabelSize(0.05);
        axisy[i+5]->SetLabelSize(0.05);
//        axisy[i]->SetMoreLogLabels(1);
//        axisy[i]->SetNoExponent();
        axisy[i]->Draw();
        axisy[i+5]->Draw();
    }
    TPaveText * pave = new TPaveText(.0, y[0], x[0]*.5, y[5]);
    pave->SetBorderSize(0);
    pave->SetFillStyle(0);
    pave->SetTextSize(0.05);
    (TText *)pave->AddText("FB correlation strength b")->SetTextAngle(90);
    pave->Draw();
    TPaveText * pave1 = new TPaveText(x[0], 0, x[2], y[0]*.5);
    pave1->SetBorderSize(0);
    pave1->SetFillStyle(0);
    pave1->SetTextSize(0.05);
    (TText *)pave1->AddText("#Delta#eta_{ref}")->SetTextAngle(0);
    pave1->Draw();

    TLatex tl;
    tl.SetTextSize(0.15);
    tl.SetTextFont();
    for(ideltaeta = 0; ideltaeta < ndeltaEta; ideltaeta ++)
    {
        pad[ideltaeta]->cd();
        sprintf(name, "#Delta#eta = %1.1f", .2*(ideltaeta+1) );
        tl.DrawLatexNDC(.4,.8, name);
    }

    pad[9]->cd();
    pad[9]->SetGrid(0,0);
    TLegend leg(.1,.1,.9,.9);
    leg.SetFillStyle(0);
    leg.SetBorderSize(0);
    leg.SetTextFont();
    leg.SetTextSize(0.12);
    for(int i = 0; i < ncendeg; i ++)
    {
        sprintf(name, "%d%%~%d%%", i*10, (i+1)*10 );
        leg.AddEntry(gr[0][i],name,"p");
    }
    leg.Draw();
    cc->DrawClone();
//____________________________CLEAR_________________________ 
    delete pave1;
    delete pave;
    for(int i = 0; i < 10; i ++)
        delete axisy[i];
    for(int i = 0; i < 4; i ++)
        delete axisx[i];
    delete [] axisy;
    delete [] axisx;
    delete haxis;
    for(int i = 0; i < ndeltaEta+1; i ++)
        delete pad[i];
    delete [] pad;
    delete cc;
    for(ideltaeta = 0; ideltaeta < ndeltaEta; ideltaeta ++)
        for(icen = 0; icen < ncendeg; icen ++)
            delete gr[ideltaeta][icen];
    for(ideltaeta = 0; ideltaeta < ndeltaEta; ideltaeta ++)
        delete [] gr[ideltaeta];
    delete [] gr;
</pre><pre name="code" class="cpp">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值