Re: [ROOT] several pads

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue May 21 2002 - 08:15:12 MEST


Hi Vincent,

I have modified/simplified your loop in your code below. See comments

Rene Brun

Vincent =?iso-8859-15?q?R=E9gnard?= wrote:
> 
> Hi,
> I have 1D histos stored in a .root files and I would like to plot them in
> different pads within a canvas. I manage to do so (see how in the following
> lines). I am running into trouble when I want to modify the pads properties.
> I would like to set xlogscale and ylogscale for each pad and modify the
> xaxislabelsize but cannot manage to obtain the pads pointers.
>  I have been trying using the GetSelected() method but it
> revealed unsuccessfull leading to the following error message in cint:
> 
> "Error: illegal pointer to class object tmpcan 0x0 331  FILE:multiview.C
> LINE:40
> *** Interpreter error recovered ***"
> I saw GetSelcted() returns a TVirtualPad , I did not understand the goal of
> this class, is there a way to convert such an object into a standard TPad ?
> 
> If you have any idea how I could sort out this I would be thankfull.
> 
> _______________________________________________
> {
> 
> /* multiview.C*/
> int entires;
> NB_MAX_HIST0 = 25;
> int index = 0;
> int i;
> TH1F * h1_array[25];
> /*executable statements*/
> TIter nextkey( f->GetListOfKeys() );
> TKey * key;
> 
> printf("Max number of histo : %d\n",25);
> 
> while ( (key = (TKey*)nextkey()) && (index < 25))
> {/*store histos in an array*/
>     h1_array[index] = (TH1F*)key->ReadObj();
> 
>     index ++;
> }
> 
> /*set the number of pads*/
> nb_x = (int)sqrt(index);
> nb_y = (int)sqrt(index);
> printf("nb_x * nb_y = %d \n",nb_x*nb_y);
> if ((nb_x * nb_y) < index) {nb_y+=1;};
> printf("nb_x * nb_y = %d \n",nb_x*nb_y);
> if ((nb_x * nb_y) < index) {nb_x+=1;};
> printf("Creating a %d * %d pad\n",nb_x,nb_y);
> 
> TCanvas * can = new TCanvas("can","canvas");
> can->Divide(nb_x,nb_y);
> 
> /*draw stuff in different pads*/
> for (i=1;i<=index;i++)
> {
    //TPad * tmpcan = new TPad(); WHY DO YOU CREATE A NEW PAD ?
    can->cd(i);  //AFTER cd, gPad points to the current pad
    gPad->SetLogx();
 
    h1_array[i-1]->Draw();
> }
> 
> printf("Read %d histos\n",index);
> 
> printf("Exiting \n");
> /*end of program*/
> }
> 
> _____________________________________________
> --
> 
>   ,           ,
>  /             \
> ((__-^^-,-^^-__))
>  `-_---' `---_-'
>   `--|o` 'o|--'
>      \  `  /
>       ): :(
>       :o_o:
>        "-"   http://www.gnu.org



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