Your script runs correctly with the CVS version and should also work with 4.00/06. The problem had been fixed early May by Olivier. Rene Brun On Tue, 29 Jun 2004, Stanley Forrester wrote: > I have a script which draws several histograms on the same TCanvas and > adds a TLegend. As displayed the font color in the legend is black. If > saved in .ps format the font color is still black. > > If I save the image in the .pdf format the font colors in the legend > match the color of the previous line's marker. How can I fix this? > > I'm using root version 4.00/02, and linux redhat 7.3 > > script follows > /////////////////////////////////////////////////////////////////// > > // script to test .pdf output 04.06.25 > // execution is > // .L test_pdf.C > // test_pdf() > > int test_pdf() { // begin function > > char htitle[100], hinfo[100]; > > sprintf(htitle, "test pdf "); > sprintf(hinfo, "test TLegend font colors (PDF)"); > > TH1F * h1 = new TH1F(htitle, hinfo, 250, 150, 400); > h1->SetMarkerColor(2); > h1->SetMarkerStyle(20); > > TH1F * h2 = new TH1F(htitle, hinfo, 250, 150, 400); > h2->SetMarkerColor(3); > h2->SetMarkerStyle(21); > > TH1F * h3 = new TH1F(htitle, hinfo, 250, 150, 400); > h3->SetMarkerColor(4); > h3->SetMarkerStyle(22); > > TH1F * h4= new TH1F(htitle, hinfo, 250, 150, 400); > h4->SetMarkerColor(5); > h4->SetMarkerStyle(23); > > for (Int_t i=1; i != 25; ++i) { // begin loop on i > float iEvent = 10.0 * i + 150.0; > h1->Fill(iEvent, iEvent*iEvent); > h2->Fill(iEvent, iEvent*iEvent/2.0); > h3->Fill(iEvent, iEvent*10.0); > h4->Fill(iEvent, iEvent*100.0); > } // end loop on i > > TCanvas* c1 = new TCanvas("c1","",200,10,700,780); > c1->SetFillColor(10); > c1->SetGrid(); > c1->Draw(); > > h1->Draw("P"); > h2->Draw("psame"); > h3->Draw("psame"); > h4->Draw("psame"); > > TLegend *leg = new TLegend(0.7,0.7,0.89,0.89); > > leg->AddEntry( h1,"histo h1","P"); > leg->AddEntry( h2,"histo h2","P"); > leg->AddEntry( h3,"histo h3","P"); > leg->AddEntry( h4,"histo h4","P"); > leg->Draw(); > > c1->SaveAs("PDF_output.pdf"); > c1->SaveAs("Postscript_output.ps"); > > return 0; > } // end function >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET