This is an up-to-date ROOT “v5-34-00-patches” here (Ubuntu 10.04.4 LTS / i686, gcc 4.4.3) …
A “minimal” working example: [code]{
TF1 *f1 = new TF1(“f1”, “TMath::BreitWigner(x,[0],[1])”, -10, 10);
f1->SetLineColor(kBlue);
f1->SetParameters(-3, 3);
TF1 *f2 = new TF1(“f2”, “TMath::Gaus(x,[0],[1],1)”, -10, 10);
f2->SetLineColor(kBlack);
f2->SetParameters(3, 3);
TLegend *legend = new TLegend(0.55, 0.72, 0.88, 0.88, “”, “brNDC”);
legend->SetFillColor(gStyle->GetCanvasColor());
legend->AddEntry(f1, “Breit-Wigner (X#mu=-3.0,X#Gamma=3.0)”, “l”);
legend->AddEntry(f2, “Gaussian (X#mu=3.0,X#sigma=3.0)”, “l”);
TCanvas *canvas = new TCanvas(“canvas”,“canvas”);
f1->Draw(“L”);
f2->Draw(“L SAME”);
legend->Draw();
canvas->SaveAs(“canvas.eps”);
canvas->SaveAs(“canvas.pdf”);
canvas->SaveAs(“canvas.gif”);
canvas->SaveAs(“canvas.jpg”);
}[/code] Compare the saved vector graphics files (".eps", “.pdf”) with the saved raster graphics files (".gif", “.jpg”). Note that in the saved raster graphics files there is a “space character” in the middle of “X#mu”, “X#Gamma”, “X#sigma”, which should NOT be there (and in fact everything is fine in the saved vector graphics files).
Another question is … if I do NOT say “legend->SetFillColor(gStyle->GetCanvasColor());”, the legend is “grey” … while the whole canvas is “white” … shouldn’t the “FillColor” of the legend be automatically set the same as the “CanvasColor”?