Dear ROOTers,
I recently found a strange error moving from 530 to 532/533 release
of ROOT.
It concerns the method "BuildLegend" (very useful!).
The following code worked well in the previous release [1], while it
doesn't in the 532/533.
The error I get is:
Error: Can't call TVirtualPad::BuildLegend() in current scope (tmpfile):1:
With a minor change of the code [2] it worked, but I cannot figure out
why the code [1] doesn't work.
It seems that it is related to "gPad".
Thanks,
Andrea
[1]
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 = gPad->BuildLegend();
leg->SetFillColor(kWhite);
gPad->SetGrid();
[2]
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:43:03 CET
This archive was generated by hypermail 2.2.0 : Wed Dec 07 2011 - 11:50:02 CET