# Draw TBox & TGraph combined

Dear Rooters,

For my plots I was trying to marks the 5% and 10% levels.
My plots are made with TGraphErrrors(), combined with TMultigraph() and then plotted on the canvas. (Plotting of the multigraph etc. is working perfectly tho)

After drawing the Multigraph I draw my box. However, nothing appears. I do not understand why.

Cheers,
Johan

``````Here is part of my syntax:
------------------------------------------------------
TBox** tlevel = SetLevels(xmin,xmax);
mg_PlotRatio[iloop]->Draw("aP");
tlevel.Draw();
c->cd(iloop+1)->Update();
------------------------------------------------------

TBox** SetLevels(double xmin, double xmax){

TBox** tlevels = new TBox*;
for(int jj=0;jj<2;jj++){ //use box around 0 / 1
tlevels[jj] = new TBox;
for(int ii=0;ii<2;ii++){ //use 5% / 10% level
tlevels[jj][ii] = TBox(xmin, ((double) jj) - 0.05*(((double) ii) + 1.), xmax, ((double) jj) +0.05*(((double) ii) + 1.));
tlevels[jj][ii].SetFillColor((ii == 0 ? 38 : 40));
}
}
return tlevels;
}
``````

It works for me:

``````void graphbox() {
TCanvas *c = new TCanvas("c","A Simple Graph with a box",700,500);

const Int_t n = 10;
TGraph *gr = new TGraph(n);
gr->SetTitle("A Simple Graph Example");
gr->SetMarkerStyle(20);

Double_t x, y;
for (Int_t i=0;i<n;i++) {
x = i*0.1;
y = 10*sin(x+0.2);
gr->SetPoint(i,x,y);

}

gr->Draw("ALP");

TBox *box = new TBox(0.1,2.,0.8,8.);
box ->Draw();
}
``````

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