RE: Filling area under a curve

From: Olivier Couet <>
Date: Wed, 7 Jun 2006 17:36:41 +0200


I have recently implemented this in TGraph. See $ROOTSYS/tutorials/graphpolar.C
This has been introduced in the last ROOT release. See:

Cheers, Olivier Couet

-----Original Message-----
[] On Behalf Of Alexander Wagner Sent: Wednesday, June 07, 2006 5:13 PM
To: Roottalk
Subject: [ROOT] Filling area under a curve


In some of my plots I want to show an excluded area by just shading it in gray. To this end I tried the following

   TH2F *Shade = new TH2F("excl", "", xbins, xmin, xmax, ybins, ymin, ymax);

   for( Double_t x = xmin; x < xmax; x += (xmax-xmin)/xbins) {

      for(Double_t y = ymin; y < ymax; y += (ymax-ymin)/ybins) {
         val = curve(y, x);
         if (val <= excl) {
               Shade->FindBin(x,y), 500);

else { Shade->SetBinContent( Shade->FindBin(x,y), 0);

   Double_t contours[1];
   contours[0] = excl;
   Shade->SetContour(1, contours);

Now, unfortunately root fills the area _above_ the curve in black (I did not even find how to change that colour) and not the one below. I always get it displayed in white, wheras I'd like something like gray70. Actually the area above the curve should be transparent so that I could Draw("cont4,same"), above another graph. Searching arround did not give me a clue (though I came accros some other interesting things ;)

Does anybody have a hint how to do this?

Many thanks in advance!

(Running root 5.10/00 @debian sarge.)


Kind regards,                /                 War is Peace.
                            |            Freedom is Slavery.
Alexander Wagner            |         Ignorance is Strength.
                            | Theory     : G. Orwell, "1984"
                           /  In practice:   USA, since 2001
Received on Wed Jun 07 2006 - 17:36:47 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET