# Colored band

Hi rooters,
how is it possible to make a colored band with TGraph or other methods?
I mean something like this (the gray band);
physics.aps.org/view_image/2614/medium/2
NT

see example below and laso \$ROOTSYS/tutorials/graphs/exclusionGraph.C and exclusionGraph2.C

Rene

``````void grshade() {
TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

c1->SetGrid();
c1->DrawFrame(0,0,2.2,12);

const Int_t n = 20;
Double_t x[n], y[n],ymin[n], ymax[n];
Int_t i;
for (i=0;i<n;i++) {
x[i] = 0.1+i*0.1;
ymax[i] = 10*sin(x[i]+0.2);
ymin[i] = 8*sin(x[i]+0.1);
y[i] = 9*sin(x[i]+0.15);
}
TGraph *grmin = new TGraph(n,x,ymin);
TGraph *grmax = new TGraph(n,x,ymax);
TGraph *gr    = new TGraph(n,x,y);
for (i=0;i<n;i++) {
}
grmin->Draw("l");
grmax->Draw("l");
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->Draw("CP");
}
``````

That’s what I was searching for,
thank you
NT

You said that the exclusion zone facility answer your question, that’s fine but on your plot I see that the gray band width varies along the X axis. The exclusion zone facility does not allow to draw such bands with variable width (the width is fixed). To draw a variable width band you should use a TGraphErrors and draw it with the option “3” as shown here:
root.cern.ch/root/html/TGraphPainter.html#GP03a

[quote=“couet”]You said that the exclusion zone facility answer your question, that’s fine but on your plot I see that the gray band width varies along the X axis. The exclusion zone facility does not allow to draw such bands with variable width (the width is fixed). To draw a variable width band you should use a TGraphErrors and draw it with the option “3” as shown here:
root.cern.ch/root/html/TGraphPainter.html#GP03a[/quote]

Hi,
I know that exclusiongraph.C draws a fixed-width band (not good for my purpose),
but the code quoted by Brun is somewhat different: the gray area is defined point by point.