Shading a TGraph

Hello

I’m obviously doing something daft, but cannot spot it. The relevant code is below. I’d like the regions between the lines shaded.

Double_t ya[27],xx[27];
TGraph grshade = new TGraph(227);
for (i=0;i<27;i++) {
xx[i]=60+i5;
ya[i]=exp(alpha
pow(log(xx[i]),2)+beta*log(xx[i])+gamma);
grshade->SetPoint(i,xx[i],ya[i]); //goes along the top line
grshade->SetPoint(27+i,xx[27-i-1],ya[27-i-1]-0.7); //comes back (<-) along the bottom line
}
grshade->SetFillStyle(3013);
grshade->SetFillColor(16);
grshade->Draw(“f”);

Cheers!



nicey.C (4.25 KB)

a simple printf gives the answer:

      printf("%d %g %g %d %g %g\n",i,xx[i],ya[i],27+i,xx[27-i-1],ya[27-i-1]-0.7);
      grshade->SetPoint(i,xx[i],ya[i]);
      grshade->SetPoint(27+i,xx[27-i-1],ya[27-i-1]-0.7);
0 60 2.42682 27 0 -0.7
1 65 2.33762 28 0 -0.7
2 70 2.26058 29 0 -0.7
3 75 2.19335 30 0 -0.7
4 80 2.13414 31 0 -0.7
5 85 2.08157 32 0 -0.7
6 90 2.0346 33 0 -0.7
7 95 1.99235 34 0 -0.7
8 100 1.95416 35 0 -0.7
9 105 1.91946 36 0 -0.7
10 110 1.8878 37 0 -0.7
11 115 1.8588 38 0 -0.7
12 120 1.83215 39 0 -0.7
13 125 1.80756 40 125 1.10756
14 130 1.78482 41 120 1.13215
15 135 1.76373 42 115 1.1588
16 140 1.74412 43 110 1.1878
17 145 1.72585 44 105 1.21946
18 150 1.70878 45 100 1.25416
19 155 1.69281 46 95 1.29235
20 160 1.67783 47 90 1.3346
21 165 1.66377 48 85 1.38157
22 170 1.65055 49 80 1.43414
23 175 1.63809 50 75 1.49335
24 180 1.62634 51 70 1.56058
25 185 1.61525 52 65 1.63762
26 190 1.60475 53 60 1.72682

point 27 is out of range.