Colors writing a Canvas in a root file

From: helsens <clement.helsens_at_cern.ch>
Date: Tue, 4 Jan 2011 14:49:41 +0100


Dear ROOTers,

I'm a bit desperate finding the solution to my problem, so I write you this mail.
What I want to do is simple I guess, but I did not succeed. I would like to keep the colors of the TH1F histos when drawing TH1F in a TCanvas.
  TFile * m_OutputFile = new TFile("ControlPlots.root","recreate");   m_OutputFile->cd();

  TH1F* tmpup = (TH1F*)nom->Clone();
  TH1F* tmpdo = (TH1F*)nom->Clone();

...//some operations
...

  TCanvas * ctmp = new TCanvas(cname,cname);   ctmp->cd();

  tmpup->SetDirectory(0);
  tmpup->SetMaximum(maxH*1.2);
  tmpup->SetMinimum(minH*1.2);
  tmpup->SetLineColor(2);
  tmpup->SetMarkerColor(2);
  tmpup->Draw("HIST");

  tmpdo->SetDirectory(0);
  tmpdo->SetLineColor(4);

  tmpdo->SetMarkerColor(4);
  tmpdo->Draw("HIST SAME");
  leg->AddEntry(tmpdo, "-1#sigma","lep");
  leg->AddEntry(tmpup, "+1#sigma","lep");
  leg->Draw();

  ctmp->Write();

then in the ControlPlots.root, the colors of the two TH1F are black... But doing
  ctmp->Print("test.png");

gives the correct colors on the .png.
Any idea how to get the colors of the TH1 in the TCanvas in the TFile?

Thanks,
Clément Received on Tue Jan 04 2011 - 14:49:49 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 05 2011 - 11:50:01 CET