Re: "[ROOT] how to superimpose two shaded regions "

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Sep 12 2002 - 14:46:58 MEST


an example below.

Rene Brun


{
   const Int_t n = 13;
   Double_t x[n] = {80,90,100,110,120,130,140,150,160,170,180,190,200};
   Double_t y[n] =
{1.8e-05,2.5e-05,3.2e-05,4.0e-05,5.2e-05,0.06,0.134,0.21,0.3,0.40,.568,0.86,1.0};
   Double_t z[n] =
{5.4e-05,9.0e-05,2.04e-04,4.5e-04,9.8e-04,0.52,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
   Double_t xmin = 80, ymin = 1e-5, xmax = 200, ymax = 1;
   Double_t xmin = 80, zmin = 1e-5, xmax = 200, zmax = 1;



   TGraph *g = new TGraph(n,x,y);
 
   TCanvas *c1 = new TCanvas("c1");
   c1->SetLogy();
   c1->DrawFrame(xmin,ymin,xmax,ymax);
   g->SetLineColor(2);
   g->Draw("l");
 
   //make a new graph using the previous graph points
   //+ the corner points of the pad to shade the region above.
   TGraph *gabove = new TGraph(n+3);
   for (Int_t i=0;i<n;i++) gabove->SetPoint(i,x[i],y[i]);
   gabove->SetPoint(n,xmax,ymax);
   gabove->SetPoint(n+1,xmin,ymax);
   gabove->SetPoint(n+2,xmin,ymin);
   gabove->SetFillColor(4);
   gabove->SetFillStyle(3004);
   gabove->Draw("f"); 
   //make a new graph using the previous graph points
   //+ the corner points of the pad to shade the regin below
   TGraph *gbelow = new TGraph(n+3);
   for (Int_t i=0;i<n;i++) gbelow->SetPoint(i,x[i],y[i]);
   gbelow->SetPoint(n,xmax,ymin);
   gbelow->SetPoint(n+1,xmin,ymin);
   gbelow->SetPoint(n+2,xmin,y[0]);
   gbelow->SetFillColor(2);
   gbelow->SetFillStyle(3008);
   gbelow->Draw("f"); 
}


On Wed, 11 Sep 2002, Subhendu Chakrabarti wrote:

> 
> 
>   
> Hi
> 	I want to superimose two shaded regions with different style.Each
> shaded region is one side of one graph. Each region can be plotted
> separately by following script. X axis is same for both.
> 
> Thanks..
> Subhendu Chakrabarti
> ***********************************************
> Double_t x[n] = {80,90,100,110,120,130,140,150,160,170,180,190,200};
> Double_t y[n]
> ={1.8e-05,2.5e-05,3.2e-05,4.0e-05,5.2e-05,0.06,0.134,0.21,0.3,0.40,.568,0.86,1.0}
> ;
> Double_t
> z[n]={5.4e-05,9.0e-05,2.04e-04,4.5e-04,9.8e-04,0.52,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
> Double_t xmin = 80, ymin = 1e-5, xmax = 200, ymax = 1;
> Double_t xmin = 80, zmin = 1e-5, xmax = 200, zmax = 1;
> 
> 
> 
> TGraph *g = new TGraph(n,x,y);
>  
>    TCanvas *c1 = new TCanvas("c1");
>    c1->SetLogy();
>    c1->DrawFrame(xmin,ymin,xmax,ymax);
>    g->SetLineColor(2);
>    g->Draw("l");
>  
>    //make a new graph using the previous graph points
>    //+ the corner points of the pad.
>    TGraph *gabove = new TGraph(n+3);
>    for (Int_t i=0;i<n;i++) gabove->SetPoint(i,x[i],y[i]);
>    gabove->SetPoint(n,xmax,ymax);
>    gabove->SetPoint(n+1,xmin,ymax);
>    gabove->SetPoint(n+2,xmin,ymin);
>    gabove->SetFillColor(4);
>    gabove->SetFillStyle(3004);
>    gabove->Draw("f"); 
>                
> 
>                 
> 
> 
> 
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:09 MET