Re: [ROOT] Fill colour of TBox, TPave, etc. from TStyle

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Tue Sep 04 2001 - 12:48:15 MEST


Hi Rene, 

On Tue, 4 Sep 2001 08:51:33 +0200 (METDST)
Rene Brun <Rene.Brun@cern.ch> wrote
concerning "Re: [ROOT] Fill colour of TBox, TPave, etc. from TStyle":
> Hi Christian,
> If you save a TCanvas that contains a TLegend as a macro,
> all the properties of the TLegend should be saved in the macro.
> I suppose that when you will execute the generated macro,
> you want to get the original object attributes and not
> the current style attributes.

I'm afraid it doesn't.  If you try the following in root: 

  TCanvas* c = new TCanvas;
  c->SetFillColor(0);
  c->SetBorderMode(0);
  c->SetBorderSize(0);
  TH1* h1 = new TH1F("h1", "h1", 100, 0, 10);
  TH1* h2 = new TH1F("h2", "h2", 100, 0, 10);
  TRandom* r = new TRandom;
  for (Int_t i = 0; i < 1000; i++) h1->Fill(r->Gaus(5, 2));
  for (Int_t i = 0; i < 1000; i++) h2->Fill(r->Poisson(5));
  h1->SetLineColor(2);
  h2->SetLineColor(3);
  h2->Draw();
  h1->Draw("SAME");
  TLegend* l = new TLegend(.5, .8, .8, .95, "Legend");
  l->AddEntry(h1, "Gaussian", "L");
  l->AddEntry(h2, "Poissonian", "L");
  l->SetFillColor(0);
  l->Draw();
  c->Print("c.C")
 
I'm afraid when you execute c.C that the legend comes up with a gray
background, rather than the white one I specified.  Looking at the
generated file, I see 

  TLegend *leg = new TLegend(0.5,0.8,0.8,0.95,NULL,"brNDC");
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillStyle(1001);

but nowhere is the fill colour set.  

<grin>It almost goes without saying, that I'm using ROOT
3.02/00.</grin> 

Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET