Re: BuildLegend and gPad

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Wed, 7 Dec 2011 08:55:07 +0000

I see the same behavior on my Mac.
Seems to me it is CINT related as the message tells that BuildLegend cannot be called.

I would also recommend you create your histograms with "new" as you are using "->" to access the Draw(0 method:

void buildlegend()
{
 TH1F *h1 = new TH1F("h1","h1",100,-2,2);  TH1F *h2 = new TH1F("h2","h2",100,-2,2);

 h1->FillRandom("gaus",10000);
 h2->FillRandom("gaus",10000);

 h1->SetLineColor(kRed);
 h2->SetLineColor(kBlue);

 TCanvas* cc = new TCanvas ("cc","cc",400,400);  h1->Draw();
 h2->Draw("same");

 TLegend* leg = cc->BuildLegend();
 leg->SetFillColor(kWhite);
 cc->SetGrid();
}

On Dec 7, 2011, at 9:43 AM, Andrea Massironi wrote:

> TH1F h1("h1","h1",100,-2,2);
> TH1F h2("h2","h2",100,-2,2);
>
> h1->FillRandom("gaus",10000);
> h2->FillRandom("gaus",10000);
>
> h1->SetLineColor(kRed);
> h2->SetLineColor(kBlue);
>
> TCanvas* cc = new TCanvas ("cc","cc",400,400);
> h1->Draw();
> h2->Draw("same");
>
> TLegend* leg = cc->BuildLegend();
> leg->SetFillColor(kWhite);
> cc->SetGrid();
Received on Wed Dec 07 2011 - 09:55:14 CET

This archive was generated by hypermail 2.2.0 : Thu Dec 08 2011 - 11:50:01 CET