Re: SetFillColor for Frames

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Dec 06 1999 - 14:38:51 MET


Hi Tassilo,
Thanks for pointing out this inconsistency in the tutorials.
I have updated the Root tutorials page to reflect changes made to Root
already
some time ago.
The problem is the following.
The Frame object TFrame is only created when the canvas is painting the
graph.
You should move two statements setting the frame attributes after the
Update
statement. see my changes in your code below

Rene Brun

Christ Tassilo wrote:
> 
> Hi rooters!
> 
> The macro below is taken from the root tutorials and my output differs
> from the one posted on the web in that I cannot get the boundaries of the
> histogram to be painted in a different color than the canvas.
> I suppose c1->GetFrame->SetFillColor(...) is supposed to do this, but
> the whole canvas is painted with the color set by c1->setFillColor(...).
> What am I doing wrong?
> 
> Tassilo
> 
>   gROOT->Reset();
>   c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
> 
>   c1->SetFillColor(4);
>   c1->SetGridx();
>   c1->SetGridy();
>   // c1->GetFrame()->SetFillColor(2);  // 2 statements moved below
>   // c1->GetFrame()->SetBorderSize(12);
> 
>   Float_t x[20], y[20];
>   for (Int_t i=0;i<n;i++) {
>     x[i] = i*0.1;
>     y[i] = 10*sin(x[i]+0.2);
>     printf(" i %i %f %f \n",i,x[i],y[i]);
>   }
>   gr = new TGraph(n,x,y);
>   gr->SetFillColor(19);
>   gr->SetLineColor(2);
>   gr->SetLineWidth(4);
>   gr->SetMarkerColor(4);
>   gr->SetMarkerStyle(21);
>   gr->Draw("ACP");
> 
>   c1->Update();
    c1->GetFrame()->SetFillColor(2);
    c1->GetFrame()->SetBorderSize(12);
>   gr->GetHistogram()->SetXTitle("X title");
>   gr->GetHistogram()->SetYTitle("Y title");
> 
> -------------------------------------------------------------------------------
> Tassilo Christ
> 
> State University of NY at Stony Brook
> PHENIX-Experiment at BNL
> 
> Campus:                                 Private:
> Department of Physics and Astronomy     Schomburg A 112 - C,
> Office C116                             350 North Loop Road
>                                         11790 Stony Brook, NY
> Telephone 516-632-9007                  Telephone 516-216-5106
> 
> BNL- phone: 516 - 344 - 5455
> 
> "Microsoft spel chekker four sail, worx grate!"
> "A world without walls and fences could live without Windows and Gates..."
> 
> And my personal favourite:
> esa$ gcc -Wall -o ariane5 ariane4.c
> ariane4.c: 666: warning: long float implicitly truncated to unsigned type
> esa$ ariane5
> 
> :->
> -------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET