Re: [ROOT] problem using TH2F::SetContour(,)

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Wed Jun 18 2003 - 15:34:28 MEST


Can you try this one:

{
   TH2F *h = new TH2F("h","test contours",60,-3,3,60,-3,3);
   for (Int_t i=0;i<100000;i++) {
      double x,y;
      gRandom->Rannor(x,y);
      h->Fill(x,y);
   }
   h->SetMinimum(0.99);
   Double_t max = h->GetMaximum();

   double contours[3];
   contours[0] = 0.1*max;
   contours[1] = 0.2*max;
   contours[2] = 0.7*max;

   h->SetContour(3,contours);
   h->Draw("cont1");

}

it should produce 3 non equidistant contours. At least it does on my Linux 
RedHat PC using root 3.05/05

 Cheers,        

 O.Couet




On Wed, 18 Jun 2003, Matthieu Lechowski wrote:

> Hello,
> 
> I do not succeed specifying my own levels of contour for 2D histograms.
> 
> In a ROOT script (I load a program .c then I call a function), I do:
>   TH2F* contour=new TH2F("contour","contour",nbinsX,xbins,nbinsY,ybins);
>   //...filling "contour"
>   Double_t levels[17];
>   levels[0]=1.864
>   levels[1]=5.
>   //...filling "levels" non-equidistant
>   contour->SetContour(17,levels); // <<----- ######
>   // NB: definition of this function in TH1 class
>   contour->Draw("cont1");
> 
> My plot has 17 levels, OK, but they are equidistant !
> 
> When I want be sure that ROOT has understood "levels", I do (in my
> function too):
>   Double_t levels2[50];
>   int ncontours=contour->GetContour(levels2);
>   for(int i=0;i<ncontours;++i)
>     cout<<levels2[i]<<endl;
> and I have exactly the same values that "levels", so it seems OK.
> 
> The funny thing is that, after having done all that in the function, I
> redo in interactive the check with "levels2", and I have not the
> values of "levels", but the values of 17 equidistant levels (so as it
> is drawn)!
> 
> So what happens ??
> Have anybody an idea?
> (I hope that I gave a not too dark explanation)
> Thank you.
> 
> Matthieu Lechowski.
> 
> PS: I'm using ROOT on lxplus at cern, with environment:
> export ROOTSYS=/afs/cern.ch/sw/root/v3.04.02/rh72_gcc2953/root;
> export PATH=$ROOTSYS/bin:$PATH;
> export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
> 
> 

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET